docbrown/app/views/internal/users/edit.html.erb
Jess Lee f50247f089 Fix conditional so super admins can ban older spammers (#1651)
* allow superadmins to band old spammers

* enhance flash notification and show all new users

* fix confirm dialog
2019-01-29 15:01:04 -05:00

45 lines
2.8 KiB
Text

<h1>
<%= @user.name%><a href="/<%= @user.username %>" target="_blank"> (@<%= @user.username %>)</a>
</h1>
<p><u><a style="color: green" href="/internal/users/<%= @user.id %>">click here view user details & take other actions</a></u></p>
<p><em>Member since <%= @user.created_at.strftime("%b %e '%y") %></em></p>
<p><strong>Activity:</strong></p>
<ul>
<li><%= @user.comments.size %> comments</li>
<li><%= @user.articles.size %> articles</li>
<li><%= @user.reactions.size %> reactions</li>
</ul>
<div class="row">
<h2>Banish User</h2>
<% if @user.comments.where("created_at < ?", 100.days.ago).empty? && @user.created_at < 100.days.ago %>
<p><em>This is extremely destructive. Banishing will delete all the user's existing content and change their username to @spam_###.</em></p>
<p><strong>Do not do this lightly.</strong></p>
<%= form_for(@user, :url => banish_internal_user_path(@user), :html => {:method => :post, :onsubmit => "return confirm('Are you sure? This is extremely destructive and irreversible. Banishing will delete all articles and turn their username into @spam_###')"}) do %>
<button class="btn btn-danger" style="font-size:2em;">Banish User for Spam</button>
<% end %>
<% elsif current_user.has_role?(:super_admin) %>
<p><strong>This is not a new user.</strong> You are only allowed to take this action because you are a <strong>super admin.</strong></p>
<p><em>This is extremely destructive. Banishing will delete all the user's existing content and change their username to @spam_###.</em></p>
<p><strong>Do not do this lightly.</strong></p>
<%= form_for(@user, :url => banish_internal_user_path(@user), :html => {:method => :post, :onsubmit => "return confirm('Are you sure? This is extremely destructive and irreversible.Banishing will delete all articles and turn their username into @spam_###')"}) do %>
<button class="btn btn-danger" style="font-size:2em;">Banish User for Spam!</button>
<% end %>
<% else %>
<p><em>This is not a new user so you'll need to contact a super admin to banish this user.</em></p>
<% end %>
</div>
<div class="row">
<h2>Fully Delete User</h2>
<% if current_user.has_role?(:super_admin) %>
<p>This will <strong>completely destroy the user</strong> and all of their activity from our database. This action is irreversible.</p>
<p><strong>Do not do this lightly.</strong></p>
<%= form_for(@user, :url => full_delete_internal_user_path(@user), :html => {:method => :post, :onsubmit => "return confirm('Are you sure? This is extremely destructive and irreversible.')"}) do %>
<button class="btn btn-danger" style="font-size:2em;">Fully Delete User & All Activity</button>
<% end %>
<% else %>
<p>Only super admins can fully delete users.</p>
<% end %>
</div>