From b86deb5b8af828bb25993b69ee80d766afdd472c Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Tue, 5 Jul 2016 18:35:11 +0300 Subject: [PATCH] Add a planned cfp end date to conferences --- app/controllers/management/conferences_controller.rb | 2 +- app/models/conference.rb | 8 ++++++++ app/views/management/conferences/_form.html.slim | 1 + config/locales/bg.yml | 2 ++ ...60705153038_add_planned_cfp_end_date_to_conferences.rb | 5 +++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160705153038_add_planned_cfp_end_date_to_conferences.rb diff --git a/app/controllers/management/conferences_controller.rb b/app/controllers/management/conferences_controller.rb index 9dc5a8c..7b4e4a9 100644 --- a/app/controllers/management/conferences_controller.rb +++ b/app/controllers/management/conferences_controller.rb @@ -52,7 +52,7 @@ module Management def conference_params params.require(:conference).permit( - :title, :email, :start_date, :end_date, :description, :host_name, + :title, :email, :start_date, :end_date, :description, :host_name, :planned_cfp_end_date, event_types_attributes: [:id, :name, :description, :maximum_length, :minimum_length, :_destroy], tracks_attributes: [:id, :name, :color, :css_class, :description, diff --git a/app/models/conference.rb b/app/models/conference.rb index 093bb85..3d816f6 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -2,9 +2,11 @@ class Conference < ActiveRecord::Base validates :title, presence: true, uniqueness: true validates :email, presence: true, format: {with: /\A[^@]+@[^@]+\z/} validates :description, presence: true + validates :planned_cfp_end_date, presence: true validates :start_date, presence: true validates :end_date, presence: true validate :start_date_is_before_end_date + validate :planned_cfp_end_date_is_before_start_date translates :title, :description @@ -39,6 +41,12 @@ class Conference < ActiveRecord::Base private + def planned_cfp_end_date_is_before_start_date + if planned_cfp_end_date.present? and start_date.present? and planned_cfp_end_date > start_date + errors.add(:planned_cfp_end_date, :cannot_be_after_start_date) + end + end + def start_date_is_before_end_date if start_date.present? and end_date.present? and start_date > end_date errors.add(:end_date, :cannot_be_before_start_date) diff --git a/app/views/management/conferences/_form.html.slim b/app/views/management/conferences/_form.html.slim index df17157..d551b33 100644 --- a/app/views/management/conferences/_form.html.slim +++ b/app/views/management/conferences/_form.html.slim @@ -8,6 +8,7 @@ = f.input :title = f.input :email = f.input :host_name + = f.input :planned_cfp_end_date = f.input :start_date, as: :date = f.input :end_date, as: :date = f.input :description diff --git a/config/locales/bg.yml b/config/locales/bg.yml index fa94938..842b2ed 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -39,6 +39,7 @@ bg: end_date: "Крайна дата" host_name: "Домейн" start_date: "Начална дата" + planned_cfp_end_date: "Планиран край на зова за лектори" title: "Заглавие" event: abstract: "Резюме" @@ -286,6 +287,7 @@ bg: email: Email на организаторския екип end_date: "Денят, в който конференцията приключва" start_date: "Денят, в който конференцията започва" + planned_cfp_end_date: "Денят, преди който, всички желаещи трябва да са изпратили предложенията си. Това поле е от информативен характер." title: "Заглавието на конференцията" tracks: color: "Цвят" diff --git a/db/migrate/20160705153038_add_planned_cfp_end_date_to_conferences.rb b/db/migrate/20160705153038_add_planned_cfp_end_date_to_conferences.rb new file mode 100644 index 0000000..cf9e0b9 --- /dev/null +++ b/db/migrate/20160705153038_add_planned_cfp_end_date_to_conferences.rb @@ -0,0 +1,5 @@ +class AddPlannedCfpEndDateToConferences < ActiveRecord::Migration + def change + add_column :conferences, :planned_cfp_end_date, :date + end +end