Merge pull request #20 from ignisf/event-types

Add Event Type editing to the Conference form
This commit is contained in:
Petko Bordjukov 2015-07-19 20:57:36 +03:00
commit 36d27ad3a8
8 changed files with 44 additions and 1 deletions

View File

@ -2,6 +2,7 @@ module Management
class ConferencesController < ManagementController
def new
@conference = Conference.new
@conference.event_types.build(name: 'Event type 1')
@conference.tracks.build(name: 'Track 1')
@conference.halls.build(name: 'Hall 1')
end
@ -51,6 +52,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]
)

View File

@ -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

View File

@ -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}

View File

@ -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}

View File

@ -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

View File

@ -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'

View File

@ -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:

View File

@ -0,0 +1,5 @@
class AddDescriptionToEventTypes < ActiveRecord::Migration
def change
add_column :event_types, :description, :text
end
end