Permalink
Browse files

Merge pull request #253 from CristinaRO/Issue_2522_del_works

Yay, looks good!
  • Loading branch information...
2 parents d3bd864 + e62b004 commit ba9fd4eeabb1772a54433db3b7a604fb0ebd4886 @shalott shalott committed Oct 14, 2011
@@ -6,8 +6,8 @@ class WorksController < ApplicationController
before_filter :load_collection
before_filter :users_only, :only => [ :new, :create, :import, :import_multiple, :drafts, :preview, :show_multiple ]
before_filter :check_user_status, :only => [:new, :create, :edit, :update, :preview, :show_multiple, :edit_multiple ]
- before_filter :load_work, :only => [ :show, :navigate, :edit, :update, :destroy, :preview, :edit_tags, :update_tags ]
- before_filter :check_ownership, :only => [ :edit, :update, :destroy, :preview ]
+ before_filter :load_work, :only => [ :show, :navigate, :edit, :update, :confirm_delete, :destroy, :preview, :edit_tags, :update_tags ]
+ before_filter :check_ownership, :only => [ :edit, :update, :confirm_delete, :destroy, :preview ]
before_filter :check_visibility, :only => [ :show, :navigate ]
before_filter :set_author_attributes, :only => [ :new, :create, :edit, :update, :manage_chapters, :preview, :show, :navigate ]
before_filter :set_instance_variables, :only => [ :new, :create, :edit, :update, :manage_chapters, :preview, :show, :navigate, :import ]
@@ -492,6 +492,9 @@ def preview_tags
@preview_mode = true
end
+ def confirm_delete
+ end
+
# DELETE /works/1
def destroy
@work = Work.find(params[:id])
@@ -39,4 +39,4 @@
</div>
<% # NOTE: the div id="workskin" is DELIBERATELY not closed in this file! %>
-
+
@@ -5,20 +5,20 @@
<li><%= link_to ts("Add Chapter"), new_work_chapter_path(@work) %></li>
<li><%= link_to ts("Edit"), edit_work_path(@work) %></li>
<li><%= link_to ts("Edit Tags"), edit_tags_work_path(@work) %></li>
- <li><%= link_to ts("Delete"), @work, :confirm => "Are you sure you want to delete this work PERMANENTLY? This CANNOT BE UNDONE and all bookmarks, comments, and kudos will be lost.", :method => :delete %></li>
+ <li><%= link_to ts("Delete"), confirm_delete_work_path(@work) %></li>
<% end %>
<% # chapter navigation %>
<% if @previous_chapter || @next_chapter %>
- <li><%= link_to "Entire Work", work_path(@work, :view_full_work => 'true') %></li>
+ <li><%= link_to ts("Entire Work"), work_path(@work, :view_full_work => 'true') %></li>
<% if @previous_chapter %>
- <li><%= link_to '&#8592; '.html_safe + h(ts("Previous Chapter")), [@work, @previous_chapter] %></li>
+ <li><%= link_to '&#8592; '.html_safe + ts("Previous Chapter"), [@work, @previous_chapter] %></li>
<% end %>
<% if @next_chapter %>
- <li><%= link_to h(ts('Next Chapter')) + ' &#8594;'.html_safe, [@work, @next_chapter] %></li>
+ <li><%= link_to (ts("Next Chapter") + " &#8594;").html_safe, [@work, @next_chapter] %></li>
<% end %>
<li class="chapter" aria-haspopup="true">
@@ -31,17 +31,18 @@
<li>
<%= form_tag url_for({:controller => :chapters, :action => :show, :work_id => @work}), :method => :get do %>
<p>
- <%= select_tag :selected_id, options_from_collection_for_select(@chapters, :id, :abbreviated_display_title, params[:id].to_i) %>
- <span class="submit actions"><%= submit_tag "Go" %></span>
+ <% options = @chapters.map{|c| [c.abbreviated_display_title.html_safe, c.id] } %>
+ <%= select_tag :selected_id, options_for_select(options, params[:id].to_i) %>
+ <span class="submit actions"><%= submit_tag ts("Go") %></span>
</p>
<% end %>
</li>
- <li><%= link_to 'Full-page index', navigate_work_path(@work) %></li>
+ <li><%= link_to ts("Full-page index"), navigate_work_path(@work) %></li>
<li><a class="chapter_index_close close" style="cursor: pointer;" title="Close Chapter Index">X</a></li>
</ul>
</li>
<% elsif @chapters %>
- <li><%= link_to 'View chapter by chapter', [@work, @chapter] %></li>
+ <li><%= link_to ts("View chapter by chapter"), [@work, @chapter] %></li>
<% end %>
@@ -55,7 +56,7 @@
<% end %>
<% end %>
- <li><%= link_to "Comments", (params[:view_full_work] == 'true' ? work_path(@work, :view_full_work => 'true', :show_comments => true, :anchor => 'comments') : url_for(:show_comments => true, :anchor => 'comments')) %></li>
+ <li><%= link_to ts("Comments"), (params[:view_full_work] == 'true' ? work_path(@work, :view_full_work => 'true', :show_comments => true, :anchor => 'comments') : url_for(:show_comments => true, :anchor => 'comments')) %></li>
<!-- allow user to disable style on work if it has been customized -->
<% if @work.work_skin %>
@@ -0,0 +1,12 @@
+<!--Descriptive page name, messages and instructions-->
+<h2 id="work-form-heading"><%= ts("Delete Work?") %></h2>
+
+<!--main content-->
+<%= form_for(@work, :html => {:method => :delete}) do |f| %>
+ <p><%= ts("Are you sure you want to delete the work %{work_title} PERMANENTLY? This CANNOT BE UNDONE and all bookmarks, comments, and kudos will be lost. If you just want to remove your association with the work, you could Orphan it instead.", :work_title => @work.title).html_safe %></p>
+ <p>
+ <%= f.submit ts("Yes, Delete Work") %>
+ <%= link_to ts("Back to the work"), @work %>
+ </p>
+<% end %>
+<!--/content-->
View
@@ -244,6 +244,7 @@
get :preview_tags
put :update_tags
get :marktoread
+ get :confirm_delete
end
resources :bookmarks
resources :chapters do
@@ -227,6 +227,13 @@
visit tag_works_path(tag, :page => "")
end
+When /^I delete the work "([^\"]*)"$/ do |work|
+ work = Work.find_by_title!(work)
+ visit work_url(work)
+ And %{I follow "Delete"}
+ click_button("Yes, Delete Work")
+end
+
### THEN
Then /^I should see Updated today$/ do
@@ -3,38 +3,26 @@ Feature: Delete Works
Check that everything disappears correctly when deleting a work
Scenario: Deleting a minimally valid work
- Given basic tags
- And all emails have been delivered
- And I am logged in as "newbie" with password "password"
- When I go to the new work page
- And I select "Not Rated" from "Rating"
- And I check "No Archive Warnings Apply"
- And I fill in "Fandoms" with "Supernatural"
- And I fill in "Work Title" with "All Hell Breaks Loose"
- And I fill in "content" with "Bad things happen, etc."
- And I press "Preview"
- And I press "Post"
- Then I should see "Work was successfully posted."
- When I go to the works page
- Then I should see "All Hell Breaks Loose"
- When I follow "All Hell Breaks Loose"
- And I follow "Delete"
+ Given I am logged in as "newbie"
+ And I post the work "All Hell Breaks Loose"
+ When I delete the work "All Hell Breaks Loose"
Then I should see "Your work All Hell Breaks Loose was deleted."
And "newbie" should be emailed
- # TODO: Figure out why these steps aren't working even though the feature is fine
+ # TODO: Figure out why these steps aren't working even though the feature is fine (multipart email?)
# And the email should contain "All Hell Breaks Loose"
- #And the email should contain "Your story All Hell Breaks Loose was deleted at your request."
- #And the email should contain "If you have questions, please contact Support (http://archiveofourown.org/support)."
- #And the email should contain "Attached is a copy of your work for your reference."
- #And the email should contain "Bad things happen, etc."
+ # And the email should contain "Your story All Hell Breaks Loose was deleted at your request."
+ # And the email should contain "If you have questions, please contact Support (http://archiveofourown.org/support)."
+ # And the email should contain "Attached is a copy of your work for your reference."
+ # And the email should contain "Bad things happen, etc."
When I go to the works page
Then I should not see "All Hell Breaks Loose"
When I go to newbie's user page
Then I should not see "All Hell Breaks Loose"
+ # TODO: refactor the scenarios below >.<
Scenario: Deleting minimally valid work when you have more than one pseud
Given basic tags
- And I am logged in as "newbie" with password "password"
+ And I am logged in as "newbie"
And "newbie" creates the pseud "Pointless Pseud"
And I follow "Edit"
And I check "Is default"
@@ -52,8 +40,7 @@ Feature: Delete Works
Then I should see "Work was successfully posted."
When I go to the works page
Then I should see "All Hell Breaks Loose"
- When I follow "All Hell Breaks Loose"
- And I follow "Delete"
+ When I delete the work "All Hell Breaks Loose"
Then I should see "Your work All Hell Breaks Loose was deleted."
And 1 email should be delivered
When I go to the works page
@@ -205,9 +192,7 @@ Feature: Delete Works
And I am logged in as "thorough" with password "something"
When I go to giftee's user page
Then I should see "Gifts (1)"
- When I follow "Gifts (1)"
- And I follow "All Something Breaks Loose"
- And I follow "Delete"
+ When I delete the work "All Something Breaks Loose"
Then I should see "Your work All Something Breaks Loose was deleted."
When I go to giftee's user page
Then I should see "Gifts (0)"
@@ -17,6 +17,12 @@ $j(document).ready(function() {
});
$j('#hide-notice-banner').click(function () { $j('#notice-banner').hide(); });
setupTooltips();
+
+ // replace all GET delete links with their AJAXified equivalent
+ $j('a[href$="/confirm_delete"]').each(function(){
+ this.href = this.href.replace(/\/confirm_delete$/, "");
+ $j(this).attr("data-method", "delete").attr("data-confirm", "Are you sure? This CANNOT BE UNDONE!");
+ });
});
function visualizeTables() {

0 comments on commit ba9fd4e

Please sign in to comment.