Merge pull request #2969 from cpradio/pr-add-category-to-group-posts

FEATURE: Add category to Group Post Listing
This commit is contained in:
Robin Ward 2014-11-17 16:02:15 -05:00
commit 0b0cee4e07
5 changed files with 12 additions and 4 deletions

View File

@ -7,6 +7,7 @@
<span class="title"> <span class="title">
<a href="{{unbound url}}">{{unbound title}}</a> <a href="{{unbound url}}">{{unbound title}}</a>
</span> </span>
<span class="category">{{category-link category}}</span>
{{#if byName}} {{#if byName}}
<span class="name"> <span class="name">
{{unbound byName}} {{unbound byName}}

View File

@ -452,12 +452,13 @@
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.name { .name {
display: block; display: inline-block;
font-size: 14px; font-size: 14px;
max-width: 400px; max-width: 400px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
vertical-align: middle;
} }
.edit-reason { .edit-reason {
background-color: scale-color($highlight, $lightness: 25%); background-color: scale-color($highlight, $lightness: 25%);

View File

@ -459,12 +459,13 @@
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.name { .name {
display: block; display: inline-block;
font-size: 14px; font-size: 14px;
max-width: 400px; max-width: 400px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
vertical-align: middle;
} }
.edit-reason { .edit-reason {
background-color: scale-color($highlight, $lightness: 25%); background-color: scale-color($highlight, $lightness: 25%);

View File

@ -38,7 +38,7 @@ class Group < ActiveRecord::Base
def posts_for(guardian, before_post_id=nil) def posts_for(guardian, before_post_id=nil)
user_ids = group_users.map {|gu| gu.user_id} user_ids = group_users.map {|gu| gu.user_id}
result = Post.where(user_id: user_ids).includes(:user, :topic).references(:posts, :topics) result = Post.where(user_id: user_ids).includes(:user, :topic, :topic => :category).references(:posts, :topics, :category)
.where('topics.archetype <> ?', Archetype.private_message) .where('topics.archetype <> ?', Archetype.private_message)
.where(post_type: Post.types[:regular]) .where(post_type: Post.types[:regular])

View File

@ -5,7 +5,8 @@ class GroupPostSerializer < ApplicationSerializer
:title, :title,
:url, :url,
:user_title, :user_title,
:user_long_name :user_long_name,
:category
has_one :user, serializer: BasicUserSerializer, embed: :objects has_one :user, serializer: BasicUserSerializer, embed: :objects
@ -24,5 +25,9 @@ class GroupPostSerializer < ApplicationSerializer
def include_user_long_name? def include_user_long_name?
SiteSetting.enable_names? SiteSetting.enable_names?
end end
def category
object.topic.category
end
end end