- def to_xml_node
- el1 = XML::Node.new "user"
- el1["display_name"] = display_name.to_s
- el1["account_created"] = creation_time.xmlschema
- if home_lat && home_lon
- home = XML::Node.new "home"
- home["lat"] = home_lat.to_s
- home["lon"] = home_lon.to_s
- home["zoom"] = home_zoom.to_s
- el1 << home
+ # A normal account is active
+ event :activate do
+ transitions :from => :pending, :to => :active
+ end
+
+ # Used in test suite, not something that we would normally need to do.
+ if Rails.env.test?
+ event :deactivate do
+ transitions :from => :active, :to => :pending
+ end
+ end
+
+ # To confirm an account is used to override the spam scoring
+ event :confirm do
+ transitions :from => [:pending, :active, :suspended], :to => :confirmed
+ end
+
+ # To unconfirm an account is to make it subject to future spam scoring again
+ event :unconfirm do
+ transitions :from => :confirmed, :to => :active
+ end
+
+ # Accounts can be automatically suspended by spam_check
+ event :suspend do
+ transitions :from => [:pending, :active], :to => :suspended
+ end
+
+ # Unsuspending an account moves it back to active without overriding the spam scoring
+ event :unsuspend do
+ transitions :from => :suspended, :to => :active
+ end
+
+ # Mark the account as deleted but keep all data intact
+ event :hide do
+ transitions :from => [:pending, :active, :confirmed, :suspended], :to => :deleted
+ end
+
+ event :unhide do
+ transitions :from => [:deleted], :to => :active
+ end
+
+ # Mark the account as deleted and remove personal data
+ event :soft_destroy do
+ before do
+ remove_personal_data
+ end
+
+ transitions :from => [:pending, :active, :confirmed, :suspended], :to => :deleted