Introduce Volunteer Teams
This commit is contained in:
parent
1be10c446c
commit
098d36c197
|
@ -5,6 +5,7 @@ module Management
|
||||||
@conference.event_types.build(name: 'Event type 1')
|
@conference.event_types.build(name: 'Event type 1')
|
||||||
@conference.tracks.build(name: 'Track 1')
|
@conference.tracks.build(name: 'Track 1')
|
||||||
@conference.halls.build(name: 'Hall 1')
|
@conference.halls.build(name: 'Hall 1')
|
||||||
|
@conference.volunteer_teams.build(name: 'Volunteer Team 1')
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -55,7 +56,8 @@ module Management
|
||||||
event_types_attributes: [:id, :name, :description, :maximum_length,
|
event_types_attributes: [:id, :name, :description, :maximum_length,
|
||||||
:minimum_length, :_destroy],
|
:minimum_length, :_destroy],
|
||||||
tracks_attributes: [:id, :name, :color, :description, :_destroy],
|
tracks_attributes: [:id, :name, :color, :description, :_destroy],
|
||||||
halls_attributes: [:id, :name, :_destroy]
|
halls_attributes: [:id, :name, :_destroy],
|
||||||
|
volunteer_teams_attributes: [:id, :name, :description, :color, :_destroy]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,10 +12,12 @@ class Conference < ActiveRecord::Base
|
||||||
has_many :halls
|
has_many :halls
|
||||||
has_many :event_types
|
has_many :event_types
|
||||||
has_many :events
|
has_many :events
|
||||||
|
has_many :volunteer_teams
|
||||||
has_one :call_for_participation, dependent: :destroy
|
has_one :call_for_participation, dependent: :destroy
|
||||||
has_many :participants, class_name: 'User', through: :events
|
has_many :participants, class_name: 'User', through: :events
|
||||||
|
|
||||||
accepts_nested_attributes_for :tracks, :halls, :event_types, reject_if: :all_blank, allow_destroy: true
|
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
|
||||||
|
reject_if: :all_blank, allow_destroy: true
|
||||||
|
|
||||||
after_create :create_call_for_participation
|
after_create :create_call_for_participation
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
class VolunteerTeam < ActiveRecord::Base
|
||||||
|
belongs_to :conference
|
||||||
|
|
||||||
|
validates :name, presence: true
|
||||||
|
validates :color, presence: true, format: {with: /\A#?[a-f0-9]{6}\z/i}
|
||||||
|
validates :description, presence: true
|
||||||
|
|
||||||
|
translates :name, :description
|
||||||
|
|
||||||
|
def color=(hex_triplet)
|
||||||
|
write_attribute :color, hex_triplet.gsub(/\A#/,'') if hex_triplet
|
||||||
|
end
|
||||||
|
|
||||||
|
def color
|
||||||
|
"##{read_attribute :color}"
|
||||||
|
end
|
||||||
|
end
|
|
@ -29,5 +29,11 @@
|
||||||
h2 = Track.model_name.human(count: 2).mb_chars.capitalize
|
h2 = Track.model_name.human(count: 2).mb_chars.capitalize
|
||||||
.row
|
.row
|
||||||
= render partial: 'form_tracks', locals: {form: f}
|
= render partial: 'form_tracks', locals: {form: f}
|
||||||
|
hr
|
||||||
|
.row
|
||||||
|
.col-lg-12
|
||||||
|
h2 = VolunteerTeam.model_name.human(count: 2).mb_chars.capitalize
|
||||||
|
.row
|
||||||
|
= render partial: 'form_volunteer_teams', locals: {form: f}
|
||||||
.panel-footer.text-right
|
.panel-footer.text-right
|
||||||
= f.submit class: 'btn btn-primary'
|
= f.submit class: 'btn btn-primary'
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
div#volunteer_teams
|
||||||
|
= form.simple_fields_for :volunteer_teams do |ff|
|
||||||
|
.col-lg-6
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
.panel-title
|
||||||
|
= VolunteerTeam.model_name.human.mb_chars.capitalize
|
||||||
|
= ff.link_to_remove icon(:remove), class: ['btn', 'btn-danger', 'btn-xs', 'pull-right']
|
||||||
|
|
||||||
|
.panel-body
|
||||||
|
= ff.input :name
|
||||||
|
= ff.input :color, as: :color
|
||||||
|
= ff.input :description, as: :text
|
||||||
|
.col-lg-6
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading
|
||||||
|
.panel-title
|
||||||
|
= t 'actions.new.title_m', model: VolunteerTeam.model_name.human
|
||||||
|
.panel-body.text-center
|
||||||
|
= form.link_to_add t('actions.create.button', model: VolunteerTeam.model_name.human), :volunteer_teams, data: {target: '#volunteer_teams'}, class: 'btn btn-success'
|
|
@ -72,6 +72,10 @@ bg:
|
||||||
password: "Парола"
|
password: "Парола"
|
||||||
password_confirmation: "Отново паролата"
|
password_confirmation: "Отново паролата"
|
||||||
remember_me: "Запомни ме"
|
remember_me: "Запомни ме"
|
||||||
|
volunteer_team:
|
||||||
|
name: Име
|
||||||
|
description: Описание
|
||||||
|
color: Цвят
|
||||||
errors:
|
errors:
|
||||||
models:
|
models:
|
||||||
event:
|
event:
|
||||||
|
@ -120,6 +124,9 @@ bg:
|
||||||
track:
|
track:
|
||||||
one: "поток от лекции"
|
one: "поток от лекции"
|
||||||
other: "потоци от лекции"
|
other: "потоци от лекции"
|
||||||
|
volunteer_team:
|
||||||
|
one: "екип от доброволци"
|
||||||
|
other: "екипи от доброволци"
|
||||||
user:
|
user:
|
||||||
one: "Потребител"
|
one: "Потребител"
|
||||||
other: "Потребители"
|
other: "Потребители"
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
class CreateVolunteerTeams < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
create_table :volunteer_teams do |t|
|
||||||
|
t.references :conference, index: true, foreign_key: true
|
||||||
|
t.string :color
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
VolunteerTeam.create_translation_table! name: :string, description: :text
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :volunteer_teams
|
||||||
|
VolunteerTeam.drop_translation_table!
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue