Events' contact address is no longer required.

Refs #107
This commit is contained in:
echarp 2018-04-08 23:37:12 +02:00
parent 453dba408f
commit 06d7538d73
5 changed files with 17 additions and 7 deletions

View File

@ -23,8 +23,8 @@ class Event < ApplicationRecord
validates :city, presence: true validates :city, presence: true
validates :region, presence: true validates :region, presence: true
validates :url, allow_nil: true, format: %r{\Ahttps?:\/\/.*\..*\z} validates :url, allow_nil: true, format: %r{\Ahttps?:\/\/.*\..*\z}
validates :contact, email: true validates :contact, email: true, allow_nil: true
validates :submitter, email: true, presence: false validates :submitter, email: true, presence: true
geocoded_by :full_address geocoded_by :full_address
after_validation :geocode, if: (lambda do |obj| after_validation :geocode, if: (lambda do |obj|

View File

@ -61,9 +61,9 @@
.field.url{ title: t('.url_helper') } .field.url{ title: t('.url_helper') }
= f.label :url = f.label :url
= f.url_field :url, placeholder: 'Ex: https://april.org' = f.url_field :url, placeholder: 'Ex: https://april.org'
.field.contact.required{ title: t('.contact_helper') } .field.contact{ title: t('.contact_helper') }
= f.label :contact = f.label :contact
= f.email_field :contact, required: true = f.email_field :contact
.field.submitter{ title: t('.submitter_helper') } .field.submitter{ title: t('.submitter_helper') }
= f.label :submitter = f.label :submitter
= f.email_field :submitter = f.email_field :submitter

View File

@ -0,0 +1,10 @@
# Events contacts are no longer required
class ChangeEventsNullContact < ActiveRecord::Migration[5.1]
def up
change_column :events, :contact, :string, default: '', null: true
end
def down
change_column :events, :contact, :string, default: '', null: false
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171015143615) do ActiveRecord::Schema.define(version: 20180408212139) do
create_table "active_admin_comments", force: :cascade do |t| create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace" t.string "namespace"
@ -63,7 +63,7 @@ ActiveRecord::Schema.define(version: 20171015143615) do
t.integer "region_id", limit: 4, default: 0, null: false t.integer "region_id", limit: 4, default: 0, null: false
t.integer "locality", limit: 4, default: 0, null: false t.integer "locality", limit: 4, default: 0, null: false
t.string "url", limit: 255, default: "" t.string "url", limit: 255, default: ""
t.string "contact", limit: 255, default: "", null: false t.string "contact", limit: 255, default: ""
t.string "submitter", limit: 255, default: "", null: false t.string "submitter", limit: 255, default: "", null: false
t.integer "moderated", limit: 4, default: 0, null: false t.integer "moderated", limit: 4, default: 0, null: false
t.text "tags", limit: 255, default: "" t.text "tags", limit: 255, default: ""

View File

@ -9,7 +9,7 @@ CREATE UNIQUE INDEX "index_admin_users_on_email" ON "admin_users" ("email");
CREATE UNIQUE INDEX "index_admin_users_on_reset_password_token" ON "admin_users" ("reset_password_token"); CREATE UNIQUE INDEX "index_admin_users_on_reset_password_token" ON "admin_users" ("reset_password_token");
CREATE TABLE "cities" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "majname" varchar(255) DEFAULT '' NOT NULL, "postalcode" integer(4), "inseecode" integer(4), "regioncode" integer(4), "latitude" float(24), "longitude" float(24)); CREATE TABLE "cities" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT '' NOT NULL, "majname" varchar(255) DEFAULT '' NOT NULL, "postalcode" integer(4), "inseecode" integer(4), "regioncode" integer(4), "latitude" float(24), "longitude" float(24));
CREATE INDEX "cities_name" ON "cities" ("name"); CREATE INDEX "cities_name" ON "cities" ("name");
CREATE TABLE "events" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) DEFAULT '' NOT NULL, "description" text(65535) NOT NULL, "start_time" datetime NOT NULL, "end_time" datetime NOT NULL, "city" varchar(255) DEFAULT '', "region_id" integer(4) DEFAULT 0 NOT NULL, "locality" integer(4) DEFAULT 0 NOT NULL, "url" varchar(255) DEFAULT '' NOT NULL, "contact" varchar(255) DEFAULT '' NOT NULL, "submitter" varchar(255) DEFAULT '' NOT NULL, "moderated" integer(4) DEFAULT 0 NOT NULL, "tags" varchar(255) DEFAULT '' NOT NULL, "secret" varchar(255) DEFAULT '' NOT NULL, "decision_time" datetime, "submission_time" datetime, "moderator_mail_id" varchar(32), "submitter_mail_id" varchar(32), "address" text(65535), "latitude" float(24), "longitude" float(24), "lock_version" integer(4) DEFAULT 0 NOT NULL, "place_name" varchar(255), "count" integer DEFAULT 1, "repeat" integer DEFAULT 0, "rule" text, "event_id" integer); CREATE TABLE "events" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) DEFAULT '' NOT NULL, "description" text(65535) NOT NULL, "start_time" datetime NOT NULL, "end_time" datetime NOT NULL, "city" varchar(255) DEFAULT '', "region_id" integer(4) DEFAULT 0 NOT NULL, "locality" integer(4) DEFAULT 0 NOT NULL, "url" varchar(255) DEFAULT '' NOT NULL, "contact" varchar(255) DEFAULT '', "submitter" varchar(255) DEFAULT '' NOT NULL, "moderated" integer(4) DEFAULT 0 NOT NULL, "tags" varchar(255) DEFAULT '' NOT NULL, "secret" varchar(255) DEFAULT '' NOT NULL, "decision_time" datetime, "submission_time" datetime, "moderator_mail_id" varchar(32), "submitter_mail_id" varchar(32), "address" text(65535), "latitude" float(24), "longitude" float(24), "lock_version" integer(4) DEFAULT 0 NOT NULL, "place_name" varchar(255), "count" integer DEFAULT 1, "repeat" integer DEFAULT 0, "rule" text, "event_id" integer);
CREATE INDEX "index_events_on_event_id" ON "events" ("event_id"); CREATE INDEX "index_events_on_event_id" ON "events" ("event_id");
CREATE INDEX "events_date" ON "events" ("start_time", "end_time"); CREATE INDEX "events_date" ON "events" ("start_time", "end_time");
CREATE TABLE "kinds" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "icon" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL); CREATE TABLE "kinds" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "icon" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL);