@@ -60,65 +60,64 @@ class Proposal < OpenConferenceWare::Base
6060 # Acts As State Machine
6161 include AASM
6262
63- aasm_column :status
64-
65- aasm_initial_state :proposed
66-
67- aasm_state :proposed
68- aasm_state :accepted
69- aasm_state :waitlisted
70- aasm_state :rejected
71- aasm_state :confirmed
72- aasm_state :declined
73- aasm_state :junk
74- aasm_state :cancelled
75-
76- aasm_event :accept do
77- transitions from : :proposed , to : :accepted
78- transitions from : :rejected , to : :accepted
79- transitions from : :waitlisted , to : :accepted
80- end
63+ aasm ( column : :status ) do
64+
65+ state :proposed , initial : true
66+ state :accepted
67+ state :waitlisted
68+ state :rejected
69+ state :confirmed
70+ state :declined
71+ state :junk
72+ state :cancelled
73+
74+ event :accept do
75+ transitions from : :proposed , to : :accepted
76+ transitions from : :rejected , to : :accepted
77+ transitions from : :waitlisted , to : :accepted
78+ end
8179
82- aasm_event :reject do
83- transitions from : :proposed , to : :rejected
84- transitions from : :accepted , to : :rejected
85- transitions from : :waitlisted , to : :rejected
86- end
80+ event :reject do
81+ transitions from : :proposed , to : :rejected
82+ transitions from : :accepted , to : :rejected
83+ transitions from : :waitlisted , to : :rejected
84+ end
8785
88- aasm_event :waitlist do
89- transitions from : :proposed , to : :waitlisted
90- transitions from : :accepted , to : :waitlisted
91- transitions from : :rejected , to : :waitlisted
92- end
86+ event :waitlist do
87+ transitions from : :proposed , to : :waitlisted
88+ transitions from : :accepted , to : :waitlisted
89+ transitions from : :rejected , to : :waitlisted
90+ end
9391
94- aasm_event :confirm do
95- transitions from : :accepted , to : :confirmed
96- end
92+ event :confirm do
93+ transitions from : :accepted , to : :confirmed
94+ end
9795
98- aasm_event :decline do
99- transitions from : :accepted , to : :declined
100- end
96+ event :decline do
97+ transitions from : :accepted , to : :declined
98+ end
10199
102- aasm_event :accept_and_confirm do
103- transitions from : :proposed , to : :confirmed
104- transitions from : :waitlisted , to : :confirmed
105- end
100+ event :accept_and_confirm do
101+ transitions from : :proposed , to : :confirmed
102+ transitions from : :waitlisted , to : :confirmed
103+ end
106104
107- aasm_event :accept_and_decline do
108- transitions from : :proposed , to : :declined
109- transitions from : :waitlisted , to : :declined
110- end
105+ event :accept_and_decline do
106+ transitions from : :proposed , to : :declined
107+ transitions from : :waitlisted , to : :declined
108+ end
111109
112- aasm_event :mark_as_junk do
113- transitions from : :proposed , to : :junk
114- end
110+ event :mark_as_junk do
111+ transitions from : :proposed , to : :junk
112+ end
115113
116- aasm_event :reset_status do
117- transitions from : %w( accepted rejected waitlisted confirmed declined junk cancelled ) , to : :proposed
118- end
114+ event :reset_status do
115+ transitions from : %w( accepted rejected waitlisted confirmed declined junk cancelled ) , to : :proposed
116+ end
119117
120- aasm_event :cancel do
121- transitions from : :confirmed , to : :cancelled
118+ event :cancel do
119+ transitions from : :confirmed , to : :cancelled
120+ end
122121 end
123122
124123 # Associations
@@ -262,15 +261,15 @@ def end_time
262261 # representing optional states. Of each pair, the first element is the title,
263262 # the second is the status.
264263 def titles_and_statuses
265- result = [ [ "(currently '#{ self . aasm_current_state . to_s . titleize } ')" , nil ] ]
266- result += self . aasm_events_for_current_state . map { |s |[ s . to_s . titleize , s . to_s ] } . sort_by { |title , state | title }
264+ result = [ [ "(currently '#{ self . aasm . current_state . to_s . titleize } ')" , nil ] ]
265+ result += self . aasm . events ( aasm . current_state ) . map { |s |[ s . to_s . titleize , s . to_s ] } . sort_by { |title , state | title }
267266 return result
268267 end
269268
270269 # allows an interface to state machine through update_attributes transition key
271270 attr_accessor :transition
272271 def transition = ( event )
273- send ( "#{ event } !" ) if !event . blank? && aasm_events_for_current_state . include? ( event . to_sym )
272+ send ( "#{ event } !" ) if !event . blank? && aasm . events ( aasm . current_state ) . include? ( event . to_sym )
274273 end
275274
276275 # Is this +user+ allowed to alter this proposal?
0 commit comments