diff --git a/app/controllers/management/conferences_controller.rb b/app/controllers/management/conferences_controller.rb index ac3bec6..d701596 100644 --- a/app/controllers/management/conferences_controller.rb +++ b/app/controllers/management/conferences_controller.rb @@ -51,6 +51,7 @@ module Management def conference_params params.require(:conference).permit( :title, :email, :start_date, :end_date, :description, + event_types_attributes: [:id, :name, :description, :_destroy], tracks_attributes: [:id, :name, :color, :description, :_destroy], halls_attributes: [:id, :name, :_destroy] ) diff --git a/app/models/conference.rb b/app/models/conference.rb index af860bd..c502157 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -11,10 +11,11 @@ class Conference < ActiveRecord::Base has_many :tracks has_many :halls has_many :events, through: :tracks + has_many :event_types has_one :call_for_participation, dependent: :destroy has_many :participant_profiles, class_name: 'PersonalProfile' - accepts_nested_attributes_for :tracks, :halls, reject_if: :all_blank, allow_destroy: true + accepts_nested_attributes_for :tracks, :halls, :event_types, reject_if: :all_blank, allow_destroy: true after_create :create_call_for_participation diff --git a/app/models/event.rb b/app/models/event.rb index 5c73365..f760184 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -3,6 +3,7 @@ class Event < ActiveRecord::Base has_one :track, through: :proposition, source: :proposition_accepting, source_type: Track has_one :conference, through: :track + belongs_to :event_type validates :title, presence: true validates :length, presence: true, numericality: {only_integer: true, greater_than: 0} diff --git a/app/models/event_type.rb b/app/models/event_type.rb index 5068a7f..839d604 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -1,5 +1,7 @@ class EventType < ActiveRecord::Base belongs_to :conference + has_many :events + translates :name, :description validates :name, presence: true, uniqueness: {scope: :conference, message: :must_be_unique_for_the_conference} diff --git a/app/views/management/conferences/_form.html.slim b/app/views/management/conferences/_form.html.slim index ea021dd..62283ca 100644 --- a/app/views/management/conferences/_form.html.slim +++ b/app/views/management/conferences/_form.html.slim @@ -11,6 +11,12 @@ = f.input :end_date, as: :date = f.input :description hr + .row + .col-lg-12 + h2 = EventType.model_name.human(count: 2).mb_chars.capitalize + .row + = render partial: 'form_event_types', locals: {form: f} + hr .row .col-lg-12 h2 = Hall.model_name.human(count: 2).mb_chars.capitalize diff --git a/app/views/management/conferences/_form_event_types.slim b/app/views/management/conferences/_form_event_types.slim new file mode 100644 index 0000000..cd57e83 --- /dev/null +++ b/app/views/management/conferences/_form_event_types.slim @@ -0,0 +1,20 @@ +div#event_types + = form.simple_fields_for :event_types do |ff| + .col-lg-6 + .panel.panel-default + .panel-heading + .panel-title + = EventType.model_name.human.mb_chars.capitalize + = ff.link_to_remove icon(:remove), class: ['btn', 'btn-danger', 'btn-xs', 'pull-right', ff.object.events.any? ? 'disabled' : nil] + span.clearfix + .panel-body + = ff.input :name + = ff.input :description +.col-lg-6 + .panel.panel-default + .panel-heading + .panel-title + = t 'actions.new.title_f', model: EventType.model_name.human + .panel-body + .form-group.text-center + = form.link_to_add t('actions.create.button', model: EventType.model_name.human), :event_types, data: {target: '#event_types'}, class: 'btn btn-success' diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 54d0a60..3e892db 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -63,6 +63,9 @@ bg: subject: 'Предложението ви за %{conference} за %{submission_type} „%{title}“ е одобрено' activerecord: models: + event_type: + one: вид събитие + other: видове събития hall: one: зала other: зали @@ -133,6 +136,9 @@ bg: track_id: Поток от лекции agreement: Съгласен(на) съм user: Лектор + event_type: + name: Име + description: Описание errors: models: user: diff --git a/db/migrate/20150719170422_add_description_to_event_types.rb b/db/migrate/20150719170422_add_description_to_event_types.rb new file mode 100644 index 0000000..866d842 --- /dev/null +++ b/db/migrate/20150719170422_add_description_to_event_types.rb @@ -0,0 +1,5 @@ +class AddDescriptionToEventTypes < ActiveRecord::Migration + def change + add_column :event_types, :description, :text + end +end