Skip to content

Commit

Permalink
Admin::ContentController merge action. Pass scenario publify#3
Browse files Browse the repository at this point in the history
  • Loading branch information
govorox committed Aug 21, 2013
1 parent 032013b commit 424e394
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions app/controllers/admin/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ class Admin::ContentController < Admin::BaseController
layout "administration", :except => [:show, :autosave]

cache_sweeper :blog_sweeper

def merge
unless Profile.find(current_user.profile_id).label == "admin"
flash[:error] = _("You are not allowed to perform a merge action")
redirect_to :action => :index
end

article = Article.find_by_id(params[:id])
if true ##article.merge_with(params[:merge_with])
flash[:notice] = _("Articles successfully merged!")
redirect_to :action => :index
else
flash[:notice] = _("Articles couldn't be merged")
redirect_to :action => :edit, :id => params[:id]
end
end

def auto_complete_for_article_keywords
@items = Tag.find_with_char params[:article][:keywords].strip
Expand Down Expand Up @@ -240,4 +256,5 @@ def def_build_body
def setup_resources
@resources = Resource.by_created_at
end

end
4 changes: 2 additions & 2 deletions app/views/admin/shared/_edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<% end %>
<% if @article.id and current_user.admin? %>
<div class=''>
<div>
<h4>Merge Articles</h4>
<%= form_tag :action => "merge_with", :id => @article.id do %>
<%= form_tag :action => "merge", :id => @article.id do %>
<%= label_tag "merge_with", "Article ID" %>
<%= text_field_tag "merge_with" %>
<%= submit_tag "Merge" %>
Expand Down

0 comments on commit 424e394

Please sign in to comment.