Add support for suspended and confirmed users
Replace the existing "active" and "visible" with an enumerated status that allows for extra cases. Currently we have "suspended" for users who hve triggered the spam detector and "confirmed" for users that have triggered the detector but have been confirmed as vald by an admin.
This commit is contained in:
parent
8b781bb18b
commit
5a54630b57
10 changed files with 90 additions and 38 deletions
29
db/migrate/051_add_status_to_user.rb
Normal file
29
db/migrate/051_add_status_to_user.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'lib/migrate'
|
||||
|
||||
class AddStatusToUser < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_enumeration :user_status_enum, ["pending","active","confirmed","suspended","deleted"]
|
||||
|
||||
add_column :users, :status, :user_status_enum, :null => false, :default => "pending"
|
||||
|
||||
User.update_all("status = 'deleted'", { :visible => false })
|
||||
User.update_all("status = 'pending'", { :visible => true, :active => 0 })
|
||||
User.update_all("status = 'active'", { :visible => true, :active => 1 })
|
||||
|
||||
remove_column :users, :active
|
||||
remove_column :users, :visible
|
||||
end
|
||||
|
||||
def self.down
|
||||
add_column :users, :visible, :boolean, :default => true, :null => false
|
||||
add_column :users, :active, :integer, :default => 0, :null => false
|
||||
|
||||
User.update_all("visible = true, active = 1", { :status => "active" })
|
||||
User.update_all("visible = true, active = 0", { :status => "pending" })
|
||||
User.update_all("visible = false, active = 1", { :status => "deleted" })
|
||||
|
||||
remove_column :users, :status
|
||||
|
||||
drop_enumeration :user_status_enum
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue