FEATURE: show group mentions and topics in groups page

This commit is contained in:
Sam
2015-12-01 16:52:43 +11:00
parent 0cffbf87c3
commit d1a5d8ea62
25 changed files with 202 additions and 52 deletions
+13
View File
@@ -3,6 +3,7 @@ class Group < ActiveRecord::Base
has_many :category_groups, dependent: :destroy
has_many :group_users, dependent: :destroy
has_many :group_mentions, dependent: :destroy
has_many :categories, through: :category_groups
has_many :users, through: :group_users
@@ -80,6 +81,18 @@ class Group < ActiveRecord::Base
result.order('posts.created_at desc')
end
def mentioned_posts_for(guardian, before_post_id=nil)
result = Post.joins(:group_mentions)
.includes(:user, :topic, :topic => :category)
.references(:posts, :topics, :category)
.where('topics.archetype <> ?', Archetype.private_message)
.where(post_type: Post.types[:regular])
result = guardian.filter_allowed_categories(result)
result = result.where('posts.id < ?', before_post_id) if before_post_id
result.order('posts.created_at desc')
end
def self.trust_group_ids
(10..19).to_a
end