Add extra user transitions needed by the administrators
This commit is contained in:
parent
1a11c4dc19
commit
2731e7244a
5 changed files with 59 additions and 0 deletions
|
@ -202,8 +202,10 @@ class UsersController < ApplicationController
|
|||
def set_status
|
||||
@user.activate! if params[:event] == "activate"
|
||||
@user.confirm! if params[:event] == "confirm"
|
||||
@user.unconfirm! if params[:event] == "unconfirm"
|
||||
@user.hide! if params[:event] == "hide"
|
||||
@user.unhide! if params[:event] == "unhide"
|
||||
@user.unsuspend! if params[:event] == "unsuspend"
|
||||
redirect_to user_path(:display_name => params[:display_name])
|
||||
end
|
||||
|
||||
|
|
|
@ -181,10 +181,21 @@ class User < ApplicationRecord
|
|||
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
|
||||
|
|
|
@ -145,12 +145,24 @@
|
|||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @user.may_unsuspend? %>
|
||||
<li>
|
||||
<%= link_to t(".unsuspend_user"), set_status_user_path(:event => "unsuspend", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @user.may_confirm? %>
|
||||
<li>
|
||||
<%= link_to t(".confirm_user"), set_status_user_path(:event => "confirm", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @user.may_unconfirm? %>
|
||||
<li>
|
||||
<%= link_to t(".unconfirm_user"), set_status_user_path(:event => "unconfirm", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if @user.may_hide? %>
|
||||
<li>
|
||||
<%= link_to t(".hide_user"), set_status_user_path(:event => "hide", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue