diff options
-rw-r--r-- | app/assets/stylesheets/refinery/blog/backend.css.scss | 4 | ||||
-rw-r--r-- | app/controllers/refinery/blog/admin/posts_controller.rb | 7 | ||||
-rw-r--r-- | app/views/refinery/blog/admin/posts/_form.html.erb | 9 | ||||
-rw-r--r-- | config/locales/en.yml | 3 | ||||
-rw-r--r-- | config/locales/fr.yml | 3 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | spec/controllers/refinery/blog/admin/posts_controller_spec.rb | 29 | ||||
-rw-r--r-- | spec/features/refinery/blog/admin/posts_spec.rb | 12 |
8 files changed, 69 insertions, 1 deletions
diff --git a/app/assets/stylesheets/refinery/blog/backend.css.scss b/app/assets/stylesheets/refinery/blog/backend.css.scss index e14d92b..e4ff700 100644 --- a/app/assets/stylesheets/refinery/blog/backend.css.scss +++ b/app/assets/stylesheets/refinery/blog/backend.css.scss @@ -71,3 +71,7 @@ a#copy_body_link { margin-top: 0; padding-left: 20px; } +.form-actions a.confirm-delete, #content .form-actions a.confirm-delete { + position: relative; + right: auto; +}
\ No newline at end of file diff --git a/app/controllers/refinery/blog/admin/posts_controller.rb b/app/controllers/refinery/blog/admin/posts_controller.rb index d01bba9..4eeffd0 100644 --- a/app/controllers/refinery/blog/admin/posts_controller.rb +++ b/app/controllers/refinery/blog/admin/posts_controller.rb @@ -75,6 +75,13 @@ module Refinery end end + def delete_translation + find_post + @post.translations.find_by_locale(params[:locale_to_delete]).destroy + flash[:notice] = ::I18n.t('delete_translation_success', :scope => 'refinery.blog.admin.posts.post') + redirect_to refinery.blog_admin_posts_path + end + private def post_params diff --git a/app/views/refinery/blog/admin/posts/_form.html.erb b/app/views/refinery/blog/admin/posts/_form.html.erb index 1d52c56..5cb061e 100644 --- a/app/views/refinery/blog/admin/posts/_form.html.erb +++ b/app/views/refinery/blog/admin/posts/_form.html.erb @@ -106,7 +106,14 @@ <%= render "/refinery/admin/form_actions", :f => f, :continue_editing => true, - :delete_title => t('delete', :scope => 'refinery.blog.admin.posts.post') %> + :delete_title => t('delete', :scope => 'refinery.blog.admin.posts.post'), + :before_delete_button => (link_to(t('delete_translation', :scope => 'refinery.blog.admin.posts.post'), + refinery.delete_translation_blog_admin_post_path(@post, :locale_to_delete => Globalize.locale), + :method => :post, + :data => { + :confirm => t('delete_translation_confirmation', :scope => 'refinery.blog.admin.posts.post') + }, + :class => "button confirm-delete") if Refinery::I18n.frontend_locales.many? && @post.translations.size > 1) %> <% end -%> <% content_for :stylesheets, stylesheet_link_tag('refinery/blog/backend') %> diff --git a/config/locales/en.yml b/config/locales/en.yml index cc6751f..1ad71b1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,6 +55,9 @@ en: view_live_html: 'View this blog post live <br/><em>(opens in a new window)</em>' edit: Edit this blog post delete: Remove this blog post forever + delete_translation: Remove this translation + delete_translation_confirmation: Are you sure you want to remove this translation forever ? + delete_translation_success: The translation was successfully removed. draft: Draft settings: notification_recipients: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index fe62db2..867aacc 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -55,6 +55,9 @@ fr: view_live_html: 'Voir cet article sur le site<br/><em>(Ouvre une nouvelle fenêtre)</em>' edit: Modifier cet article delete: Supprimer cet article + delete_translation: Supprimer cette traduction + delete_translation_confirmation: Êtes-vous sûr de vouloir supprimer cette traduction ? + delete_translation_success: La traduction a été correctement supprimée. draft: Brouillon settings: notification_recipients: diff --git a/config/routes.rb b/config/routes.rb index 8a7ae27..f36bc11 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,9 @@ Refinery::Core::Engine.routes.draw do get :uncategorized get :tags end + member do + post :delete_translation + end end resources :categories diff --git a/spec/controllers/refinery/blog/admin/posts_controller_spec.rb b/spec/controllers/refinery/blog/admin/posts_controller_spec.rb new file mode 100644 index 0000000..d2f1074 --- /dev/null +++ b/spec/controllers/refinery/blog/admin/posts_controller_spec.rb @@ -0,0 +1,29 @@ +require "spec_helper" + +module Refinery + module Blog + module Admin + describe PostsController, :focus do + refinery_login_with :refinery_user + + describe "#delete_translation" do + let!(:blog_post) { FactoryGirl.create(:blog_post) } + + before do + blog_post.translations.create(:locale => :fr, :title => 'Un titre francais', :body => "La baguette, c'est bon. Mangez-en.") + end + + it "destroys the translation" do + post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr + blog_post.translations.exists?(:locale => :fr).should be_false + end + + it "redirects on success" do + post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr + response.should be_redirect + end + end + end + end + end +end diff --git a/spec/features/refinery/blog/admin/posts_spec.rb b/spec/features/refinery/blog/admin/posts_spec.rb index c139b0d..8507f63 100644 --- a/spec/features/refinery/blog/admin/posts_spec.rb +++ b/spec/features/refinery/blog/admin/posts_spec.rb @@ -330,6 +330,18 @@ module Refinery end end + describe "delete the post translation in secondary locale", :focus do + it "succeeds" do + within "#post_#{blog_post.id}" do + click_link("Ru") + end + + click_link "Remove this translation" + + page.should_not have_content(blog_post.title) + page.should have_content("The translation was successfully removed.") + end + end end end |