Skip to content

Commit

Permalink
Reworked confirmation page
Browse files Browse the repository at this point in the history
Thanks to sarken the confirmation page is now significantly less hideous!

Signed-off-by: shalott <shalott@gmail.com>
  • Loading branch information
shalott committed Nov 22, 2015
1 parent ed79f2d commit ef51083
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 36 deletions.
4 changes: 2 additions & 2 deletions app/controllers/admin/admin_users_controller.rb
Expand Up @@ -167,10 +167,10 @@ def user_is_banned
end

def confirm_delete_user_creations
@works = @user.works
@works = @user.works.paginate(page: params[:works_page])
@comments = @user.comments.paginate(page: params[:comments_page])
@bookmarks = @user.bookmarks
@collections = @user.collections
@comments = @user.comments
@series = @user.series
end

Expand Down
48 changes: 21 additions & 27 deletions app/views/admin/admin_users/confirm_delete_user_creations.html.erb
Expand Up @@ -2,32 +2,26 @@
<h2 class="heading"><%= ts("Delete Spammer Creations") %></h2>

<!--main content-->
<p class="caution notice">
<%= ts("All creations will be destroyed (CANNOT BE REVERSED)") %>
</p>

<% if @works.count > 0 %>
<h3 class="heading"><%= ts("Works")%></h3>
<%= render "works/work_abbreviated_list", :works => @works %>
<% end %>
<% if @collections.count > 0 %>
<h3 class="heading"><%= ts("Collections") %></h3>
<ul>
<% @collections.each do |c| %><li><%= c.title %> (<%= c.name %>)</li><% end %>
</ul>
<% end %>

<h3 class="heading"><%= ts("Bookmarks: ")%><%= @bookmarks.count %></h3>

<h3 class="heading"><%= ts("Series: ")%><%= @series.count %></h3>

<h3 class="heading"><%= ts("Comments: ")%><%= @comments.count %></h3>

<%= form_tag destroy_user_creations_admin_user_path(@user), :method => :post do %>
<p class="submit actions"><%= submit_tag ts("Confirm Deletion"), :confirm => ts("Are you sure? Remember this will destroy ALL these objects!") %></p>
<%= form_tag destroy_user_creations_admin_user_path(@user), method: :post, class: "simple destroy" do %>

<p class="caution notice">
<%= ts('Are you sure you want to <strong><em>delete</em></strong> all the works and comments created by this user, along with their %{bookmarks} bookmarks, %{series} series, and %{collections} collections? This <strong>cannot be undone</strong>.', bookmarks: @bookmarks.count, series: @series.count, collections: @collections.count, comments: @comments.count).html_safe %>
</p>

<% if @works.count > 0 %>
<h3 class="heading"><%= ts("Works")%></h3>
<%= render "works/work_abbreviated_list", :works => @works %>
<%= will_paginate(@works, :param_name => 'works_page') %>
<% end %>
<% if @comments.count > 0 %>
<h3 class="heading"><%= ts("Comments")%></h3>
<%= render "comments/comment_abbreviated_list", :comments => @comments %>
<%= will_paginate(@comments, :param_name => 'comments_page') %>
<% end %>

<p class="actions">
<%= submit_tag ts("Yes, Delete All Spammer Creations"), confirm: ts("Are you sure? Remember this will destroy ALL these objects!") %>
</p>
<% end %>



<!--/content-->
15 changes: 15 additions & 0 deletions app/views/comments/_comment_abbreviated_list.html.erb
@@ -0,0 +1,15 @@
<% # this partial is used for an abbreviated list of unthreaded comments (by a single user) %>
<% # expects local "comments" %>

<dl class="comments index group">
<% comments.each do |comment| %>
<dt>
<%= ts("Comment on") %> <%= link_to_comment_ultimate_parent(comment) %>
<span title="datetime"><%= time_in_zone(comment.created_at) %></span>
</dt>
<dd>
<%= truncate(comment.content, length: 100, separator: ' ') %>
</dd>
<% end %>
</dl>

15 changes: 8 additions & 7 deletions features/admins/admin_manage_users.feature
Expand Up @@ -258,19 +258,20 @@ Feature: Admin Actions to manage users
And I press "Update"
Then I should see "permanently suspended"
And the user "Spamster" should be permanently banned
And I should see "All creations will be destroyed (CANNOT BE REVERSED)"
And I should see "Are you sure you want to delete"
And I should see "1 bookmarks"
And I should see "1 collections"
And I should see "1 series"
And I should see "Loads of Spam"
And I should see "Even More Spam"
And I should see "Spam 3: Tokyo Drift"
And I should see "Spam Collection"
And I should see "Series: 1"
And I should see "Bookmarks: 1"
And I should see "Comments: 1"
When I press "Confirm Deletion"
And I should see "I like spam"
When I press "Yes, Delete All Spammer Creations"
Then I should see "All creations by user Spamster have been deleted."
And the work "Loads of Spam" should be deleted
And the work "Even More Spam" should be deleted
And the work "Spam 3: Tokyo Drift" should be deleted
And the collection "Spam Collection" should be deleted
And the series "One Spam After Another" should be deleted
And the work "Not Spam" should not be deleted
And there should be no bookmarks on the work "Not Spam"
Expand All @@ -284,7 +285,7 @@ Feature: Admin Actions to manage users
And I choose "Spammer: ban and delete all creations"
And I press "Update"
And the user "Spamster" is unbanned in the background
And I press "Confirm Deletion"
And I press "Yes, Delete All Spammer Creations"
Then I should see "That user is not banned"
And the work "Loads of Spam" should not be deleted

4 changes: 4 additions & 0 deletions features/step_definitions/collection_steps.rb
Expand Up @@ -134,3 +134,7 @@
Then /^I should see a collection not found message for "([^\"]+)"$/ do |collection_name|
step %{I should see /We couldn't find the collection(?:.+and)? #{collection_name}/}
end

Then /^the collection "(.*)" should be deleted/ do |collection|
assert Collection.where(:title => collection).first.nil?
end

0 comments on commit ef51083

Please sign in to comment.