Skip to content
Permalink
Browse files

Remove 'Unassign All' feature

  • Loading branch information...
romanrizzi committed May 15, 2019
1 parent 615ad7c commit c882b097f8b538abe2da2758bdf5a08a7addf8a1
@@ -78,12 +78,6 @@ def assign
end
end

def unassign_all
user = User.find_by(id: params[:user_id])
TopicAssigner.unassign_all(user, current_user)
render json: success_json
end

private

def translate_failure(reason, user)
@@ -6,28 +6,7 @@ export default UserTopicsList.extend({
user: Ember.inject.controller(),
taskActions: Ember.inject.service(),

@computed("model.topics")
canUnassignAll(topics) {
return topics && topics.length && this.currentUser.get("staff");
},

actions: {
unassignAll() {
let user = this.get("user.model");
bootbox.confirm(
I18n.t("discourse_assign.unassign_all.confirm", {
username: user.get("username")
}),
value => {
if (value) {
ajax("/assign/unassign-all", {
type: "PUT",
data: { user_id: user.get("id") }
}).then(() => this.send("changeAssigned"));
}
}
);
},
unassign(topic) {
this.get("taskActions")
.unassign(topic.get("id"))
@@ -1,11 +1 @@
<div class='assign-controls'>
{{#if canUnassignAll}}
{{d-button
action=(action "unassignAll")
class="btn-default"
icon="times"
label="discourse_assign.unassign_all.title"}}
{{/if}}
</div>

{{outlet}}
@@ -9,9 +9,6 @@ en:
assigned: "Assigned"
assigned_to: "Assigned to"
assign_notification: "<p><span>{{username}}</span> {{description}}</p>"
unassign_all:
title: "Unassign All"
confirm: "Are you sure you want to unassign all topics from {{username}}?"
unassign:
title: "Unassign"
help: "Unassign Topic"
@@ -4,6 +4,5 @@
put "/claim/:topic_id" => "assign#claim"
put "/assign" => "assign#assign"
put "/unassign" => "assign#unassign"
put "/unassign-all" => "assign#unassign_all"
get "/suggestions" => "assign#suggestions"
end

This file was deleted.

Oops, something went wrong.
@@ -7,24 +7,6 @@ class ::TopicAssigner
ASSIGNED_TO_ID = 'assigned_to_id'
ASSIGNED_BY_ID = 'assigned_by_id'

def self.unassign_all(user, assigned_by)
topic_ids = TopicCustomField.where(name: ASSIGNED_TO_ID, value: user.id).pluck(:topic_id)

# Fast path: by doing this we can instantly refresh for the user showing no assigned topics
# while doing the "full" removal asynchronously.
TopicCustomField.where(
name: [ASSIGNED_TO_ID, ASSIGNED_BY_ID],
topic_id: topic_ids
).delete_all

Jobs.enqueue(
:unassign_bulk,
user_id: user.id,
assigned_by_id: assigned_by.id,
topic_ids: topic_ids
)
end

def self.backfill_auto_assign
staff_mention = User.where('moderator OR admin')
.pluck('username')
@@ -24,7 +24,6 @@
end

after_initialize do
require File.expand_path('../jobs/unassign_bulk.rb', __FILE__)
require File.expand_path('../jobs/scheduled/enqueue_reminders.rb', __FILE__)
require File.expand_path('../jobs/regular/remind_user.rb', __FILE__)
require 'topic_assigner'
@@ -85,12 +85,6 @@ def assert_publish_topic_state(topic, user)
.to eq(TopicUser.notification_levels[:muted])
end

it "can unassign all a user's topics at once" do
assigner.assign(moderator)
TopicAssigner.unassign_all(moderator, moderator)
expect(TopicQuery.new(moderator, assigned: moderator.username).list_latest.topics).to be_blank
end

context "when assigns_by_staff_mention is set to true" do
let(:system_user) { Discourse.system_user }
let(:moderator) { Fabricate(:admin, username: "modi") }

0 comments on commit c882b09

Please sign in to comment.
You can’t perform that action at this time.