mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Claim Reviewables by Topic
This is a feature that used to be present in discourse-assign but is much easier to implement in core. It also allows a topic to be assigned without it claiming for review and vice versa and allows it to work with category group reviewers.
This commit is contained in:
@@ -25,26 +25,36 @@ class ReviewableSerializer < ApplicationSerializer
|
||||
has_many :editable_fields, serializer: ReviewableEditableFieldSerializer, embed: :objects
|
||||
has_many :reviewable_scores, serializer: ReviewableScoreSerializer
|
||||
has_many :bundled_actions, serializer: ReviewableBundledActionSerializer
|
||||
has_one :claimed_by, serializer: BasicUserSerializer, root: 'users'
|
||||
|
||||
# Used to keep track of our payload attributes
|
||||
class_attribute :_payload_for_serialization
|
||||
|
||||
def bundled_actions
|
||||
object.actions_for(scope).bundles
|
||||
end
|
||||
|
||||
def reviewable_actions
|
||||
object.actions_for(scope).to_a
|
||||
args = {}
|
||||
args[:claimed_by] = claimed_by if @options[:claimed_topics]
|
||||
object.actions_for(scope, args).bundles
|
||||
end
|
||||
|
||||
def editable_fields
|
||||
object.editable_for(scope).to_a
|
||||
args = {}
|
||||
args[:claimed_by] = claimed_by if @options[:claimed_topics]
|
||||
object.editable_for(scope, args).to_a
|
||||
end
|
||||
|
||||
def can_edit
|
||||
editable_fields.present?
|
||||
end
|
||||
|
||||
def claimed_by
|
||||
return nil unless @options[:claimed_topics].present?
|
||||
@options[:claimed_topics][object.topic_id]
|
||||
end
|
||||
|
||||
def include_claimed_by?
|
||||
@options[:claimed_topics]
|
||||
end
|
||||
|
||||
def self.create_attribute(name, field)
|
||||
attribute(name)
|
||||
|
||||
|
@@ -13,7 +13,18 @@ class ReviewableTopicSerializer < ApplicationSerializer
|
||||
:reviewable_score
|
||||
)
|
||||
|
||||
has_one :claimed_by, serializer: BasicUserSerializer, root: 'users'
|
||||
|
||||
def stats
|
||||
@options[:stats][object.id]
|
||||
end
|
||||
|
||||
def claimed_by
|
||||
@options[:claimed_topics][object.id]
|
||||
end
|
||||
|
||||
def include_claimed_by?
|
||||
@options[:claimed_topics]
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user