Modify views for booths

This commit is contained in:
nasia 2017-06-18 23:33:54 +03:00
parent 318c0d15a4
commit 98e0a25606
10 changed files with 220 additions and 88 deletions

View file

@ -1,4 +1,6 @@
class Booth < ActiveRecord::Base
include ActiveRecord::Transitions
belongs_to :conference
has_many :booth_requests
has_many :users, through: :booth_requests
@ -13,4 +15,35 @@ class Booth < ActiveRecord::Base
: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

View file

@ -7,4 +7,6 @@ class BoothRequest < ActiveRecord::Base
:role,
presence: true
ROLES = [%w[Submitter submitter], %w[Responsible responsible], %w[Secondary secondary]]
end