Merge 98e0a25606 into a925ceac35
This commit is contained in:
commit
5a178b8dad
32 changed files with 781 additions and 2 deletions
49
app/models/booth.rb
Normal file
49
app/models/booth.rb
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
class Booth < ActiveRecord::Base
|
||||
include ActiveRecord::Transitions
|
||||
|
||||
belongs_to :conference
|
||||
has_many :booth_requests
|
||||
has_many :users, through: :booth_requests
|
||||
|
||||
validates :title,
|
||||
uniqueness: { case_sensitive: false },
|
||||
presence: true
|
||||
|
||||
validates :description,
|
||||
:reasoning,
|
||||
:state,
|
||||
:logo_link,
|
||||
:conference_id,
|
||||
presence: true
|
||||
|
||||
state_machine initial: :submitted do
|
||||
state :submitted
|
||||
state :withdrawn
|
||||
state :to_accept
|
||||
state :accepted
|
||||
state :rejected
|
||||
|
||||
event :restart do
|
||||
transitions to: :submitted, from: [:withdrawn]
|
||||
end
|
||||
event :withdrawn do
|
||||
transitions to: :withdrawn, from: [:submitted, :to_accept, :accepted]
|
||||
end
|
||||
event :to_accept do
|
||||
transitions to: :to_accept, from: [:submitted, :rejected, :accepted]
|
||||
end
|
||||
event :accept do
|
||||
transitions to: :accepted, from: [:submitted, :to_accept]
|
||||
end
|
||||
event :reject do
|
||||
transitions to: :rejected, from: [:submitted]
|
||||
end
|
||||
event :reset do
|
||||
transitions to: :submitted, from: [:to_accept]
|
||||
end
|
||||
end
|
||||
|
||||
def transition_possible?(transition)
|
||||
self.class.state_machine.events_for(current_state).include?(transition)
|
||||
end
|
||||
end
|
||||
12
app/models/booth_request.rb
Normal file
12
app/models/booth_request.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
class BoothRequest < ActiveRecord::Base
|
||||
belongs_to :booth
|
||||
belongs_to :user
|
||||
|
||||
validates :booth,
|
||||
:user,
|
||||
:role,
|
||||
presence: true
|
||||
|
||||
ROLES = [%w[Submitter submitter], %w[Responsible responsible], %w[Secondary secondary]]
|
||||
|
||||
end
|
||||
22
app/models/call_for_booth.rb
Normal file
22
app/models/call_for_booth.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class CallForBooth < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
|
||||
validates :start_date, :end_date, :booth_limit, presence: true
|
||||
validate :before_end_of_conference
|
||||
validate :start_date_before_end_date
|
||||
|
||||
private
|
||||
|
||||
def before_end_of_conference
|
||||
errors
|
||||
.add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
|
||||
|
||||
errors
|
||||
.add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
|
||||
end
|
||||
|
||||
def start_date_before_end_date
|
||||
errors
|
||||
.add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
|
||||
end
|
||||
end
|
||||
|
|
@ -16,6 +16,7 @@ class Conference < ActiveRecord::Base
|
|||
has_one :splashpage, dependent: :destroy
|
||||
has_one :contact, dependent: :destroy
|
||||
has_one :registration_period, dependent: :destroy
|
||||
has_one :call_for_booths, dependent: :destroy
|
||||
has_one :email_settings, dependent: :destroy
|
||||
has_one :program, dependent: :destroy
|
||||
has_one :venue, dependent: :destroy
|
||||
|
|
@ -24,6 +25,7 @@ class Conference < ActiveRecord::Base
|
|||
has_many :supporters, through: :ticket_purchases, source: :user
|
||||
has_many :tickets, dependent: :destroy
|
||||
has_many :resources, dependent: :destroy
|
||||
has_many :booths, dependent: :destroy
|
||||
|
||||
has_many :lodgings, dependent: :destroy
|
||||
has_many :registrations, dependent: :destroy
|
||||
|
|
|
|||
|
|
@ -50,11 +50,13 @@ class User < ActiveRecord::Base
|
|||
has_many :votes, dependent: :destroy
|
||||
has_many :voted_events, through: :votes, source: :events
|
||||
has_many :subscriptions, dependent: :destroy
|
||||
has_many :booth_requests
|
||||
has_many :booths, through: :users_booths
|
||||
accepts_nested_attributes_for :roles
|
||||
|
||||
scope :admin, -> { where(is_admin: true) }
|
||||
scope :active, -> { where(is_disabled: false) }
|
||||
|
||||
|
||||
validates :email, presence: true
|
||||
|
||||
validates :username,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue