cleanup and add mod message if needed
This commit is contained in:
parent
67169fd0e5
commit
7b0d192b57
|
@ -1,5 +1,5 @@
|
||||||
{{#d-modal-body title="discourse_assigns.assign_modal.title" class="assign"}}
|
{{#d-modal-body title="discourse_assign.assign_modal.title" class="assign"}}
|
||||||
{{i18n 'discourse_assigns.assign_modal.description'}}
|
{{i18n 'discourse_assign.assign_modal.description'}}
|
||||||
{{user-selector
|
{{user-selector
|
||||||
single=true
|
single=true
|
||||||
allowAny=false
|
allowAny=false
|
||||||
|
@ -12,5 +12,5 @@
|
||||||
{{/d-modal-body}}
|
{{/d-modal-body}}
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
{{d-button label='discourse_assigns.assign_modal.assign' icon=inviteIcon action="assign" class="btn-primary" disabled=disabled}}
|
{{d-button label='discourse_assign.assign_modal.assign' icon=inviteIcon action="assign" class="btn-primary" disabled=disabled}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{d-button class="assign"
|
{{d-button class="assign"
|
||||||
icon="user-plus"
|
icon="user-plus"
|
||||||
action="assign"
|
action="assign"
|
||||||
label="discourse_assigns.assign.title"
|
label="discourse_assign.assign.title"
|
||||||
title="discourse_assigns.assign.help"}}
|
title="discourse_assign.assign.help"}}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
en:
|
en:
|
||||||
js:
|
js:
|
||||||
discourse_assigns:
|
action_codes:
|
||||||
|
assigned: "assigned"
|
||||||
|
discourse_assign:
|
||||||
assign:
|
assign:
|
||||||
title: "Assign"
|
title: "Assign"
|
||||||
help: "Assign Topic to User"
|
help: "Assign Topic to User"
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
en:
|
||||||
|
discourse_assign:
|
||||||
|
assigned_to: "Topic assigned to @%{username}"
|
16
plugin.rb
16
plugin.rb
|
@ -37,11 +37,23 @@ SQL
|
||||||
topic_id = params.require(:topic_id)
|
topic_id = params.require(:topic_id)
|
||||||
username = params.require(:username)
|
username = params.require(:username)
|
||||||
|
|
||||||
assigned = AssignedUser.where(topic_id: topic_id).first_or_initialize
|
topic = Topic.find(topic_id.to_i)
|
||||||
assigned.assigned_to_id = User.where(username_lower: username.downcase).pluck(:id).first
|
assign_to = User.find_by(username_lower: username.downcase)
|
||||||
|
|
||||||
|
raise Discourse::NotFound unless assign_to
|
||||||
|
|
||||||
|
assigned = AssignedUser.where(topic_id: topic.id).first_or_initialize
|
||||||
|
assigned.assigned_to_id = assign_to.id
|
||||||
assigned.assigned_by_id = current_user.id
|
assigned.assigned_by_id = current_user.id
|
||||||
assigned.save!
|
assigned.save!
|
||||||
|
|
||||||
|
topic.add_moderator_post(current_user,
|
||||||
|
I18n.t('discourse_assign.assigned_to',
|
||||||
|
username: assign_to.username),
|
||||||
|
{ bump: false,
|
||||||
|
post_type: Post.types[:small_action],
|
||||||
|
action_code: "assigned"})
|
||||||
|
|
||||||
render json: {status: "ok"}
|
render json: {status: "ok"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue