Add event length limitations
This commit is contained in:
parent
f14c3bc665
commit
a87c7bd496
|
@ -52,7 +52,8 @@ module Management
|
|||
def conference_params
|
||||
params.require(:conference).permit(
|
||||
:title, :email, :start_date, :end_date, :description, :host_name,
|
||||
event_types_attributes: [:id, :name, :description, :_destroy],
|
||||
event_types_attributes: [:id, :name, :description, :maximum_length,
|
||||
:minimum_length, :_destroy],
|
||||
tracks_attributes: [:id, :name, :color, :description, :_destroy],
|
||||
halls_attributes: [:id, :name, :_destroy]
|
||||
)
|
||||
|
|
|
@ -13,14 +13,15 @@ class Event < ActiveRecord::Base
|
|||
|
||||
validates :conference, presence: true
|
||||
validates :title, presence: true
|
||||
validates :length, presence: true, numericality: {only_integer: true, greater_than: 0}
|
||||
validates :abstract, presence: true
|
||||
validates :description, presence: true
|
||||
validates :agreement, acceptance: true
|
||||
validates :track, presence: true
|
||||
validate :track_belongs_to_the_selected_conference
|
||||
validates :language, inclusion: {in: I18n.available_locales.map(&:to_s)}, presence: true
|
||||
|
||||
validates :event_type, presence: true
|
||||
validates :length, presence: true, numericality: {only_integer: true}
|
||||
validate :length_is_within_the_permitted_interval
|
||||
|
||||
scope :confirmed, -> { where.not confirmed_at: nil }
|
||||
|
||||
|
@ -35,4 +36,10 @@ class Event < ActiveRecord::Base
|
|||
errors.add :track, :must_be_a_valid_track
|
||||
end
|
||||
end
|
||||
|
||||
def length_is_within_the_permitted_interval
|
||||
unless length >= event_type.minimum_length and length <= event_type.maximum_length
|
||||
errors.add :length, :must_be_between, minimum: event_type.minimum_length, maximum: event_type.maximum_length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,8 @@ div#event_types
|
|||
.panel-body
|
||||
= ff.input :name
|
||||
= ff.input :description
|
||||
= ff.input :minimum_length
|
||||
= ff.input :maximum_length
|
||||
.col-lg-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
|
|
|
@ -47,6 +47,8 @@ bg:
|
|||
event_type:
|
||||
description: "Описание"
|
||||
name: "Име"
|
||||
minimum_length: Минимална продължителност
|
||||
maximum_length: Максимална продължителност
|
||||
hall:
|
||||
name: "Име"
|
||||
personal_profile:
|
||||
|
@ -76,6 +78,8 @@ bg:
|
|||
attributes:
|
||||
track:
|
||||
must_be_a_valid_track: "трябва да е някой от изброените потоци от лекции"
|
||||
length:
|
||||
must_be_between: "трябва да е между %{minimum} и %{maximum} минути"
|
||||
personal_profile:
|
||||
attributes:
|
||||
github:
|
||||
|
@ -238,7 +242,7 @@ bg:
|
|||
agreement: "Отбележете съгласни ли сте с това събитието Ви да бъде записано и публикувано под лиценз CC-BY-ND (Creative Commons – Attribution – No Derivatives)"
|
||||
description: "Подробно описание на предложението (няколко абзаца)"
|
||||
language: ""
|
||||
length: "Продължителността на събитието (в минути)"
|
||||
length: "Продължителността на събитието (в минути). Продължителността на %{type} е между %{min} и %{max} минути, заедно с въпросите"
|
||||
notes: "Допълнителни бележки, които искате да споделите с организаторския екип"
|
||||
subtitle: ""
|
||||
title: ""
|
||||
|
|
|
@ -47,6 +47,8 @@ en:
|
|||
event_type:
|
||||
description: Description
|
||||
name: Name
|
||||
minimum_length: Minimum length
|
||||
maximum_length: Maximum length
|
||||
hall:
|
||||
name: Name
|
||||
personal_profile:
|
||||
|
@ -76,6 +78,8 @@ en:
|
|||
attributes:
|
||||
track:
|
||||
must_be_a_valid_track: must be one of the listed lecture tracks
|
||||
length:
|
||||
must_be_between: "must be between %{minimum} and %{maximum} minutes"
|
||||
personal_profile:
|
||||
attributes:
|
||||
github:
|
||||
|
@ -202,7 +206,7 @@ en:
|
|||
are_you_sure: Are you sure you want to delete your registration
|
||||
cancel_my_account: Delete my account
|
||||
edit_account: Edit account
|
||||
leave_blank_if_you_do_not_want_to_change: leave blank if you don't want to change it
|
||||
leave_blank_if_you_do_not_want_to_change: "leave blank if you don't want to change it"
|
||||
minimum_characters: at least %{minimum} symbols
|
||||
sign_me_up: Sign me up
|
||||
sign_up: Registration
|
||||
|
@ -237,8 +241,8 @@ en:
|
|||
abstract: An abstract of the event that will be published for the attendees to read (around 1 paragraph)
|
||||
agreement: Indicate if you accept your workshop to be recorded and published under the CC-BY-ND (Creative Commons – Attribution – No Derivatives) license
|
||||
description: Detailed description of the event (several paragraphs)
|
||||
language: ""
|
||||
length: Length of the event
|
||||
language: "Language"
|
||||
length: "Length of the event (in minutes). The length of a %{type} is between %{min} and %{max} minutes"
|
||||
notes: Notes that you'd like the organisation team to read
|
||||
subtitle: ""
|
||||
title: ""
|
||||
|
|
|
@ -8,10 +8,7 @@
|
|||
= form.input :title, autofocus: true
|
||||
= form.input :subtitle
|
||||
= form.association :track, wrapper: :default, collection: current_conference.tracks.map { |track| [track.name, track.id, {title: track.description}] }
|
||||
|
||||
-# TODO length is different for different types of events (translation problem)
|
||||
= form.input :length
|
||||
|
||||
= form.input :length, hint: t('simple_form.hints.event.length', type: @event.event_type.name.mb_chars.downcase, min: @event.event_type.minimum_length, max: @event.event_type.maximum_length)
|
||||
= form.input :language, as: :radio_buttons, collection: locale_collection, include_blank: false, wrapper: :default, checked: current_user.language
|
||||
= form.input :abstract
|
||||
= form.input :description
|
||||
|
|
Loading…
Reference in New Issue