Setup booth group mvc
This commit is contained in:
parent
e3f175d55a
commit
64cb6ec456
7 changed files with 99 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ class Booth < ApplicationRecord
|
|||
attr_accessor :invite_responsible
|
||||
|
||||
belongs_to :conference
|
||||
belongs_to :booth_group
|
||||
has_many :booth_requests, dependent: :destroy
|
||||
has_many :users, through: :booth_requests
|
||||
|
||||
|
|
|
|||
23
app/models/booth_group.rb
Normal file
23
app/models/booth_group.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BoothGroup < ApplicationRecord
|
||||
belongs_to :program, touch: true
|
||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||
has_many :booths, dependent: :restrict_with_error
|
||||
|
||||
accepts_nested_attributes_for :booths
|
||||
|
||||
validates :name, presence: true
|
||||
validates :color, format: /\A#[0-9A-F]{6}\z/
|
||||
before_validation :capitalize_color
|
||||
|
||||
private
|
||||
|
||||
def capitalize_color
|
||||
self.color = color.upcase if color.present?
|
||||
end
|
||||
|
||||
def conference_id
|
||||
program.conference_id
|
||||
end
|
||||
end
|
||||
|
|
@ -52,6 +52,7 @@ class Conference < ApplicationRecord
|
|||
through: :program,
|
||||
source: :events
|
||||
has_many :event_types, through: :program
|
||||
has_many :booth_groups, through: :program
|
||||
|
||||
has_many :surveys, as: :surveyable, dependent: :destroy do
|
||||
def for_registration
|
||||
|
|
@ -683,9 +684,10 @@ class Conference < ApplicationRecord
|
|||
# we have different start indices for every collection to generate a
|
||||
# different color for every of them.
|
||||
start_index = {
|
||||
tracks: (program.tracks.count + 1),
|
||||
levels: (program.difficulty_levels.count + 51),
|
||||
types: (program.event_types.count + 101)
|
||||
tracks: (program.tracks.count + 1),
|
||||
levels: (program.difficulty_levels.count + 51),
|
||||
types: (program.event_types.count + 101),
|
||||
booth_groups: (program.booth_groups.count + 151)
|
||||
}
|
||||
next_color(start_index[collection])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class Program < ApplicationRecord
|
|||
|
||||
has_many :cfps, dependent: :destroy
|
||||
has_many :event_types, dependent: :destroy
|
||||
has_many :booth_groups, dependent: :destroy
|
||||
has_many :tracks, dependent: :destroy
|
||||
has_many :difficulty_levels, dependent: :destroy
|
||||
has_many :schedules, dependent: :destroy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue