Permalink
Browse files

commented scoped moved to right place

  • Loading branch information...
1 parent b65d193 commit dbb0a893457af246d7deea4ddc734f416db6330e @will-r will-r committed Jul 5, 2011
Showing with 25 additions and 22 deletions.
  1. +12 −8 app/views/admin/dashboard/_forum_dashboard.html.haml
  2. +1 −0 config/locales/en.yml
  3. +12 −14 lib/commentable_model.rb
@@ -5,7 +5,7 @@
%h2
= t('forum_extension.latest_forum_activity')
.blockcontent
- - latest = Topic.latest(4)
+ - latest = Topic.latest(8)
- if latest.any?
- latest.each do |topic|
- post = topic.posts.last
@@ -29,13 +29,13 @@
=t('dashboard_extension.no_show')
-- if Radiant.config['forum.pages_commentable?']
- #recent_comments.dashboard_module
- .header
- %h2
- = t('forum_extension.pages_with_latest_comments')
- .blockcontent
- - latest = Page.last_commented(6)
+#recent_comments.dashboard_module
+ .header
+ %h2
+ = t('forum_extension.pages_with_latest_comments')
+ .blockcontent
+ - if Radiant.config['forum.allow_page_comments?']
+ - latest = Page.last_commented(8)
- if latest.any?
- latest.each do |page|
.page
@@ -49,3 +49,7 @@
- else
%p.minor
=t('dashboard_extension.no_show')
+ - else
+ %p.minor
+ =t('forum_extension.comments_disabled')
+
@@ -54,6 +54,7 @@ en:
other: "%{count} comments, most recently from "
comment_on_page: "a comment added to the page"
comments_closed: "Comments closed."
+ comments_disabled: "Page comments are disabled"
comments_on: "Comments on"
comments: "comments"
confirm_removal_of_comment: "Are you sure you want to delete this comment from %{author}? There's no way to get it back if you change your mind."
@@ -1,20 +1,6 @@
module CommentableModel # for inclusion into ActiveRecord::Base
def self.included(base)
base.extend ClassMethods
- base.class_eval do
- named_scope :last_commented, lambda { |count| {
- :conditions => "replied_at IS NOT NULL",
- :order => "replied_at DESC",
- :limit => count
- }}
- named_scope :most_commented, lambda { |count| {
- :select => "topics.*, count(posts.id) AS post_count",
- :joins => "INNER JOIN posts ON posts.topic_id = topics.id",
- :group => "topics.id",
- :order => "post_count DESC",
- :limit => count
- }}
- end
end
module ClassMethods
@@ -30,6 +16,18 @@ def has_comments
extend CommentableModel::CommentableClassMethods
include CommentableModel::CommentableInstanceMethods
}
+ named_scope :last_commented, lambda { |count| {
+ :conditions => "replied_at IS NOT NULL",
+ :order => "replied_at DESC",
+ :limit => count
+ }}
+ named_scope :most_commented, lambda { |count| {
+ :select => "#{self.table_name}.*, count(posts.id) AS post_count",
+ :joins => "INNER JOIN posts ON posts.#{self.class.to_s.downcase}_id = #{self.table_name}.id",
+ :group => "#{self.table_name}.id",
+ :order => "post_count DESC",
+ :limit => count
+ }}
end
end

0 comments on commit dbb0a89

Please sign in to comment.