unassign can optionally not create a tracking topic

This commit is contained in:
Sam Saffron 2017-02-20 11:52:19 -05:00
parent 5da7ce9e0f
commit 581e47055c
3 changed files with 23 additions and 18 deletions

View File

@ -3,6 +3,7 @@ en:
assigns_public: "Allow general public to see topic assignments"
assigns_user_url_path: "Path to link all user links for assigned (use: {username} to subtitue username)"
assigns_by_staff_mention: "If a staff member mentions another staff member, topic is automatically assigned"
unassign_creates_tracking_post: "If you unassign a topic a whisper or small action will be created to track change"
discourse_assign:
assigned_to: "Topic assigned to @%{username}"
unassigned: "Topic was unassigned"

View File

@ -1,5 +1,6 @@
plugins:
assigns_by_staff_mention: false
unassign_creates_tracking_post: true
assigns_public: false
assigns_user_url_path:
client: true

View File

@ -127,22 +127,13 @@ SQL
true
end
def unassign()
end
end
class ::DiscourseAssign::AssignController < Admin::AdminController
before_filter :ensure_logged_in
def unassign
topic_id = params.require(:topic_id)
topic = Topic.find(topic_id.to_i)
if assigned_to_id = topic.custom_fields["assigned_to_id"]
topic.custom_fields["assigned_to_id"] = nil
topic.custom_fields["assigned_by_id"] = nil
topic.save!
if assigned_to_id = @topic.custom_fields["assigned_to_id"]
@topic.custom_fields["assigned_to_id"] = nil
@topic.custom_fields["assigned_by_id"] = nil
@topic.save!
post = topic.posts.where(post_number: 1).first
post = @topic.posts.where(post_number: 1).first
post.publish_change_to_clients!(:revised, { reload_topic: true })
assigned_user = User.find_by(id: assigned_to_id)
@ -156,19 +147,31 @@ SQL
Notification.where(
notification_type: Notification.types[:custom],
user_id: assigned_user.try(:id),
topic_id: topic.id,
topic_id: @topic.id,
post_number: 1
).where("data like '%discourse_assign.assign_notification%'")
.destroy_all
post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper]
topic.add_moderator_post(current_user,
if SiteSetting.unassign_creates_tracking_post
post_type = SiteSetting.assigns_public ? Post.types[:small_action] : Post.types[:whisper]
@topic.add_moderator_post(@assigned_by,
I18n.t('discourse_assign.unassigned'),
{ bump: false,
post_type: post_type,
action_code: "assigned"})
end
end
end
end
class ::DiscourseAssign::AssignController < Admin::AdminController
before_filter :ensure_logged_in
def unassign
topic_id = params.require(:topic_id)
topic = Topic.find(topic_id.to_i)
assigner = TopicAssigner.new(topic, current_user)
assigner.unassign
render json: success_json
end