From 5a360475a2d7846b83e23f2c05c62ade59d8bb30 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Thu, 4 Sep 2014 00:39:54 +0300 Subject: [PATCH] Add event terms acceptance requirement --- app/controllers/lectures_controller.rb | 2 +- app/controllers/workshops_controller.rb | 2 +- app/models/event.rb | 1 + app/views/lectures/_form.html.slim | 1 + app/views/workshops/_form.html.slim | 1 + config/locales/bg.yml | 2 ++ config/locales/en.yml | 2 ++ config/locales/simple_form.bg.yml | 4 +++- config/locales/simple_form.en.yml | 5 ++--- spec/factories/events.rb | 2 ++ spec/support/shared_examples/shared_examples_for_events.rb | 5 +++++ 11 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/controllers/lectures_controller.rb b/app/controllers/lectures_controller.rb index 64bcfe9..69a46b5 100644 --- a/app/controllers/lectures_controller.rb +++ b/app/controllers/lectures_controller.rb @@ -41,7 +41,7 @@ class LecturesController < ApplicationController end def lecture_params - params.require(:lecture).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id] + params.require(:lecture).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id, :agreement] end def after_save_redirection diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index bc97069..61b7350 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -41,7 +41,7 @@ class WorkshopsController < ApplicationController end def workshop_params - params.require(:workshop).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id] + params.require(:workshop).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id, :agreement] end def after_save_redirection diff --git a/app/models/event.rb b/app/models/event.rb index 3ca6fd0..b206a8a 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -4,6 +4,7 @@ class Event < ActiveRecord::Base validates :abstract, presence: true validates :description, presence: true validates :track, inclusion: { in: (Conference.current.try(:tracks) || []) } + validates :agreement, acceptance: true belongs_to :track has_one :conference, through: :track diff --git a/app/views/lectures/_form.html.slim b/app/views/lectures/_form.html.slim index 50db059..7a254f6 100644 --- a/app/views/lectures/_form.html.slim +++ b/app/views/lectures/_form.html.slim @@ -11,4 +11,5 @@ = form.input :abstract = form.input :description = form.input :notes + = form.input :agreement, as: :boolean = form.button :submit diff --git a/app/views/workshops/_form.html.slim b/app/views/workshops/_form.html.slim index d4c5026..d54d8df 100644 --- a/app/views/workshops/_form.html.slim +++ b/app/views/workshops/_form.html.slim @@ -11,4 +11,5 @@ = form.input :abstract = form.input :description = form.input :notes + = form.input :agreement, as: :boolean = form.button :submit diff --git a/config/locales/bg.yml b/config/locales/bg.yml index b066153..3fd3c45 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -58,6 +58,7 @@ bg: description: Описание notes: Забележки track: Поток от лекции + agreement: Съгласен(на) съм workshop: title: Заглавие subtitle: Подзаглавие @@ -67,6 +68,7 @@ bg: description: Описание notes: Забележки track: Поток от уъркшопи + agreement: Съгласен(на) съм errors: models: user: diff --git a/config/locales/en.yml b/config/locales/en.yml index 97b9b2f..ff1e17c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -58,6 +58,7 @@ en: description: Description (3-4 paragraphs) notes: Notes track: Track + agreement: I agree workshop: title: Title subtitle: Sub-title @@ -67,6 +68,7 @@ en: description: Description (3-4 paragraphs) notes: Notes track: Track + agreement: I agree errors: models: user: diff --git a/config/locales/simple_form.bg.yml b/config/locales/simple_form.bg.yml index a164070..71f94a2 100644 --- a/config/locales/simple_form.bg.yml +++ b/config/locales/simple_form.bg.yml @@ -29,6 +29,7 @@ bg: abstract: Резюме на лекцията, което да може да бъде прочетено от посетителите (1 абзац) description: Подробно описание на лекцията (няколко абзаца) notes: Забележки, които искате да споделите с организаторския екип + agreement: Отбележете съгласни ли Сте с това лекцията Ви да бъде записана и публикувана под лиценз CC-BY-ND (Creative Commons – Attribution – No Derivatives)? workshop: title: Заглавието на уъркшопа Ви subtitle: Подзаглавието на уъркшопа Ви (ако има такова) @@ -37,4 +38,5 @@ bg: language: Език, на който ще бъде воден уъркшопа abstract: Резюме на уъркшопа, което да може да бъде прочетено от посетителите (1 абзац) description: Подробно описание на уъркшопа (няколко абзаца) - notes: Забележки, които искате да споделите с организаторския екип \ No newline at end of file + notes: Забележки, които искате да споделите с организаторския екип + agreement: Отбележете дали Сте съгласни с това уъркшопът Ви да бъде записан и публикуван под лиценз CC-BY-ND (Creative Commons – Attribution – No Derivatives)? \ No newline at end of file diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 30512d9..37a8174 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -29,6 +29,7 @@ en: abstract: Abstract of the talk, for the visitors description: Detailed description of the talk, visible to the visitors notes: Notes on your talk, visible only to the organizers + agreement: Indicate if you accept your lecture to be recorded and published under the CC-BY-ND (Creative Commons – Attribution – No Derivatives) license? workshop: title: Title of your workshop subtitle: Sub-title of your workshop (if applicable) @@ -38,6 +39,4 @@ en: abstract: Abstract of the workshop, visible to the visitors description: Detailed description of the workshop, visible to the visitors notes: Notes, visible only to the organizers - labels: - user: - a: b + agreement: Indicate if you accept your workshop to be recorded and published under the CC-BY-ND (Creative Commons – Attribution – No Derivatives) license? diff --git a/spec/factories/events.rb b/spec/factories/events.rb index d969b63..c2b3c18 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -9,6 +9,7 @@ FactoryGirl.define do abstract "An Abstract" description "A Description" notes "Some Notes" + agreement true track user end @@ -21,6 +22,7 @@ FactoryGirl.define do abstract "An Abstract" description "A Description" notes "Some Notes" + agreement true track user end diff --git a/spec/support/shared_examples/shared_examples_for_events.rb b/spec/support/shared_examples/shared_examples_for_events.rb index a3656c0..3bb5847 100644 --- a/spec/support/shared_examples/shared_examples_for_events.rb +++ b/spec/support/shared_examples/shared_examples_for_events.rb @@ -1,4 +1,9 @@ RSpec.shared_examples 'an event' do + it 'is invalid if the event agrement is not accepted' do + event.agreement = false + expect(event).to have_error_on :agreement + end + it 'is invalid without a title' do event.title = '' expect(event).to have_error_on :title