Add new SiteSetting to disable locking of flags when assigned

This commit is contained in:
Robin Ward 2017-10-13 10:46:35 -04:00
parent a69bd40401
commit 246de40653
4 changed files with 15 additions and 9 deletions

View File

@ -12,7 +12,7 @@ function initialize(api) {
api.modifyClass('component:flagged-post', {
@computed('flaggedPost.topic.assigned_to_user_id', 'filter')
canAct(assignedToUserId, filter) {
if (assignedToUserId && this.currentUser.id !== assignedToUserId) {
if (this.siteSettings.assign_locks_flags && assignedToUserId && this.currentUser.id !== assignedToUserId) {
return false;
}

View File

@ -9,6 +9,7 @@ en:
assign_other_regex: "Regex that needs to pass for assigning topics to others via mention. Example 'your list'."
unassign_on_group_archive: "When a message is archived by a group, unassign message (reassign if moved back to inbox)"
unassign_on_close: "When a topic is closed unassign topic"
assign_locks_flags: "When a topic is assigned to a staff member, its flags can only be handled by that person"
discourse_assign:
assigned_to: "Topic assigned to @%{username}"
unassigned: "Topic was unassigned"

View File

@ -12,3 +12,6 @@ plugins:
assigns_user_url_path:
client: true
default: "/latest?assigned={username}"
assign_locks_flags:
default: true
client: true

View File

@ -20,6 +20,7 @@ after_initialize do
# Raise an invalid access error if a user tries to act on something
# not assigned to them
DiscourseEvent.on(:before_staff_flag_action) do |args|
if SiteSetting.assign_locks_flags?
if custom_fields = args[:post].topic.custom_fields
if assigned_to_id = custom_fields['assigned_to_id']
unless assigned_to_id.to_i == args[:user].id
@ -32,6 +33,7 @@ after_initialize do
end
end
end
end
TopicList.preloaded_custom_fields << "assigned_to_id"