mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 17:18:56 +08:00

Recently we introduced a new `PostList` component (d886c55f63
). In this update, we make broader adoption of this component. In particular, these areas include using the new component in the user activity stream pages, user's deleted posts, and pending posts page. This update also takes the existing `posts` route and adds a barebones front-end for it to view posts all in one page.
---------
Co-authored-by: David Taylor <david@taylorhq.com>
73 lines
1.4 KiB
Ruby
73 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "post_item_excerpt"
|
|
|
|
class GroupPostSerializer < ApplicationSerializer
|
|
include PostItemExcerpt
|
|
|
|
attributes :id,
|
|
:created_at,
|
|
:topic_id,
|
|
:topic_title,
|
|
:topic_slug,
|
|
:topic_html_title,
|
|
:url,
|
|
:category_id,
|
|
:post_number,
|
|
:posts_count,
|
|
:post_type,
|
|
:username,
|
|
:name,
|
|
:avatar_template,
|
|
:user_title,
|
|
:primary_group_name
|
|
|
|
# TODO(keegan): Remove `embed: :object` after updating references in discourse-reactions
|
|
has_one :user, serializer: GroupPostUserSerializer, embed: :object
|
|
has_one :topic, serializer: BasicTopicSerializer, embed: :object
|
|
|
|
def topic_title
|
|
object.topic.title
|
|
end
|
|
|
|
def topic_html_title
|
|
object.topic.fancy_title
|
|
end
|
|
|
|
def topic_slug
|
|
object.topic.slug
|
|
end
|
|
|
|
def posts_count
|
|
object.topic.posts_count
|
|
end
|
|
|
|
def include_user_long_name?
|
|
SiteSetting.enable_names?
|
|
end
|
|
|
|
def category_id
|
|
object.topic.category_id
|
|
end
|
|
|
|
def username
|
|
object&.user&.username
|
|
end
|
|
|
|
def name
|
|
object&.user&.name
|
|
end
|
|
|
|
def avatar_template
|
|
object&.user&.avatar_template
|
|
end
|
|
|
|
def user_title
|
|
object&.user&.title
|
|
end
|
|
|
|
def primary_group_name
|
|
object&.user&.primary_group&.name
|
|
end
|
|
end
|