Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:fdv/typo

  • Loading branch information...
commit 53c3fc62fdfac7a8a28fd1d7ee0cdebd019cd4c6 2 parents 1db1e48 + 40e85f1
@fdv fdv authored
View
32 app/controllers/admin/feedback_controller.rb
@@ -45,18 +45,6 @@ def index
end
@feedback = Feedback.where(conditions).order('feedback.created_at desc').page(params[:page]).per(this_blog.admin_display_elements)
end
-
- def article
- @article = Article.find(params[:id])
- if params[:ham] && params[:spam].blank?
- @feedback = @article.comments.ham
- end
- if params[:spam] && params[:ham].blank?
- @feedback = @article.comments.spam
- end
- @feedback ||= @article.comments
- end
-
def destroy
@record = Feedback.find params[:id]
@@ -109,12 +97,24 @@ def update
comment.attributes = params[:comment]
if request.post? and comment.save
flash[:notice] = _('Comment was successfully updated.')
- redirect_to :action => 'article', :id => comment.article.id
+ redirect_to action: 'article', id: comment.article.id
else
- redirect_to :action => 'edit', :id => comment.id
+ redirect_to action: 'edit', id: comment.id
end
end
+ def article
+ @article = Article.find(params[:id])
+ if params[:ham] && params[:spam].blank?
+ @feedback = @article.comments.ham
+ end
+ if params[:spam] && params[:ham].blank?
+ @feedback = @article.comments.spam
+ end
+ @feedback ||= @article.comments
+ end
+
+
def change_state
return unless request.xhr?
@@ -150,10 +150,10 @@ def bulkops
return
end
when 'Mark Checked Items as Ham'
- update_feedback(items, :mark_as_ham!)
+ update_feedback(items, :change_state!)
flash[:notice]= _("Marked %d item(s) as Ham",ids.size)
when 'Mark Checked Items as Spam'
- update_feedback(items, :mark_as_spam!)
+ update_feedback(items, :change_state!)
flash[:notice]= _("Marked %d item(s) as Spam",ids.size)
when 'Confirm Classification of Checked Items'
update_feedback(items, :confirm_classification!)
View
5 app/helpers/admin/feedback_helper.rb
@@ -9,11 +9,10 @@ def comment_class state
def show_feedback_actions(item, context='listing')
html = <<-HTML
<small>
-
#{published_or_not item} |
#{change_status(item, context)} |
- #{link_to _("Edit"), :controller => 'admin/feedback', :action => 'edit', :id => item.id} |
- #{link_to _("Delete"), :controller => 'admin/feedback', :action => 'destroy', :id => item.id }|
+ #{link_to _("Edit"), edit_admin_feedback_path(item.id)} |
+ #{link_to _("Delete"), admin_feedback_path(item.id), method: :delete }
#{link_to _("Show conversation"), :controller => 'admin/feedback', :action => 'article', :id => item.article_id}
</small>
HTML
View
20 app/helpers/application_helper.rb
@@ -59,26 +59,6 @@ def markup_help_popup(markup, text)
end
end
- def admin_tools_for(model)
- type = model.class.to_s.downcase
- tag = []
- tag << content_tag("div",
- link_to_remote('nuke', {
- :url => {
- :controller => "admin/feedback",
- :action => "delete",
- :id => model.id },
- :method => :post,
- :confirm => _("Are you sure you want to delete this %s?", "#{type}" )
- }, :class => "admintools") <<
- link_to('edit', {
- :controller => "admin/feedback",
- :action => "edit", :id => model.id
- }, :class => "admintools"),
- :id => "admin_#{type}_#{model.id}", :style => "display: none")
- tag.join(" | ")
- end
-
def onhover_show_admin_tools(type, id = nil)
tag = []
tag << %{ onmouseover="if (getCookie('typo_user_profile') == 'admin') { Element.show('admin_#{[type, id].compact.join('_')}'); }" }
View
6 app/views/admin/dashboard/_welcome.html.erb
@@ -13,8 +13,8 @@
<p><strong><%= _("Feedback") %></strong></p>
<ul>
- <li> <%= sprintf("%s %d", link_to(_("Total comments:"), :controller => 'admin/feedback') , @statcomments) %></li>
- <li> <%= sprintf("%s %d", link_to(_("Spam comments:"), :controller => 'admin/feedback', :published => 'f'), @statspam) %></li>
- <li> <%= sprintf("%s %d", link_to(_("In your spam queue:"), :controller => 'admin/feedback', :presumed_spam => 'f'), @presumedspam) %></li>
+ <li> <%= sprintf("%s %d", link_to(_("Total comments:"), admin_feedback_index_path) , @statcomments) %></li>
+ <li> <%= sprintf("%s %d", link_to(_("Spam comments:"), admin_feedback_index_path(published: 'f')), @statspam) %></li>
+ <li> <%= sprintf("%s %d", link_to(_("In your spam queue:"), admin_feedback_index_path(presumed_spam: 'f')), @presumedspam) %></li>
</ul>
</div>
View
12 app/views/admin/feedback/index.html.erb
@@ -4,22 +4,22 @@
<div class='row'>
<div class='span10'>
<span class='badge badge-inverse'>
- <%= link_to(_("All"), :controller => 'admin/feedback', :action => 'index') %>
+ <%= link_to(_("All"), admin_feedback_index_path) %>
</span>&nbsp;
<span class='badge'>
- <%= link_to(_("Unapproved comments"), :controller => 'admin/feedback', :action => 'index', :confirmed => 'f') %>
+ <%= link_to(_("Unapproved comments"), admin_feedback_index_path(confirmed: 'f')) %>
</span>&nbsp;
<span class='badge badge-success'>
- <%= link_to(_("Ham"), :controller => 'admin/feedback', :action => 'index', :ham => 'f') %>
+ <%= link_to(_("Ham"), admin_feedback_index_path(ham: 'f')) %>
</span>&nbsp;
<span class='badge badge-important'>
- <%= link_to(_("Spam"), :controller => 'admin/feedback', :action => 'index', :spam => 'f') %>
+ <%= link_to(_("Spam"), admin_feedback_index_path(spam: 'f')) %>
</span>&nbsp;
<span class='badge badge-info'>
- <%= link_to(_("Presumed ham"), :controller => 'admin/feedback', :action => 'index', :presumed_ham => 'f') %>
+ <%= link_to(_("Presumed ham"), admin_feedback_index_path(presumed_ham: 'f')) %>
</span>&nbsp;
<span class='badge badge-warning'>
- <%= link_to(_("Presumed spam"), :controller => 'admin/feedback', :action => 'index', :published => 'f') %>
+ <%= link_to(_("Presumed spam"), admin_feedback_index_path(published: 'f')) %>
</span>&nbsp;
</div>
<div class='pull-right'>
View
2  app/views/comments/_comment.html.erb
@@ -1,5 +1,5 @@
<li id="comment-<%= comment.id %>" <%= 'class="author_comment"' if comment.user %> <%= 'style="display:none"' if controller.request.xhr? %><%= onhover_show_admin_tools(:comment, comment.id) %>>
- <%= admin_tools_for comment %>
+
<p>
<a name="comment-<%= comment.id %>"></a>
<%= avatar_tag(:email => comment.email, :url => comment.url) %>
View
12 config/routes.rb
@@ -107,12 +107,22 @@
end
# Admin/XController
- %w{advanced cache categories comments content profiles feedback general pages
+ %w{advanced cache categories comments content profiles general pages
resources sidebar textfilters themes trackbacks users settings tags redirects seo post_types }.each do |i|
match "/admin/#{i}", :to => "admin/#{i}#index", :format => false
match "/admin/#{i}(/:action(/:id))", :to => "admin/#{i}", :action => nil, :id => nil, :format => false
end
+ namespace :admin do
+ resources :feedback do
+ collection do
+ post 'bulkops'
+ get 'article'
+ get 'change_state'
+ end
+ end
+ end
+
# default
root :to => 'articles#index', :format => false
View
12 spec/controllers/admin/feedback_controller_spec.rb
@@ -346,9 +346,15 @@ def feedback_from_not_own_article
end
describe '#bulkops action' do
- it 'should redirect to action' do
- post :bulkops, :bulkop_top => 'destroy all spam'
- @response.should redirect_to(:action => 'index')
+ it "redirect to index" do
+ post :bulkops, bulkop_top: 'destroy all spam'
+ @response.should redirect_to(action: 'index')
+ end
+
+ it "mark comments as spam" do
+ comment = FactoryGirl.create(:comment, state: :presumed_spam)
+ post :bulkops, bulkop_top: 'Mark Checked Items as Spam', feedback_check: {comment.id.to_s => "on"}
+ comment.reload.should be_spam
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.