mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 19:46:55 +08:00
Support for custom reasons for things being queued for approval
This commit is contained in:
parent
cf0c2d09d4
commit
c2f7676370
|
@ -228,7 +228,7 @@ export default DiscourseController.extend({
|
||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
|
|
||||||
if (result.responseJson.action === "enqueued") {
|
if (result.responseJson.action === "enqueued") {
|
||||||
self.send('postWasEnqueued', {pending_count: result.responseJson.pending_count });
|
self.send('postWasEnqueued', result.responseJson);
|
||||||
self.destroyDraft();
|
self.destroyDraft();
|
||||||
self.close();
|
self.close();
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1 +1,6 @@
|
||||||
export default Ember.Controller.extend();
|
export default Ember.Controller.extend({
|
||||||
|
description: Ember.computed('model.reason', function() {
|
||||||
|
const reason = this.get('model.reason');
|
||||||
|
return reason ? I18n.t('queue_reason.' + reason + '.description') : I18n.t('queue.approval.description');
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
|
@ -38,7 +38,8 @@ const ApplicationRoute = Discourse.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
postWasEnqueued(details) {
|
postWasEnqueued(details) {
|
||||||
showModal('post-enqueued', {model: details, title: 'queue.approval.title' });
|
const title = details.reason ? 'queue_reason.' + details.reason + '.title' : 'queue.approval.title';
|
||||||
|
showModal('post-enqueued', {model: details, title });
|
||||||
},
|
},
|
||||||
|
|
||||||
composePrivateMessage(user, post) {
|
composePrivateMessage(user, post) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>{{i18n "queue.approval.description"}}</p>
|
<p>{{{description}}}</p>
|
||||||
|
|
||||||
<p>{{{i18n "queue.approval.pending_posts" count=model.pending_count}}}
|
<p>{{{i18n "queue.approval.pending_posts" count=model.pending_count}}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,8 @@ class NewPostResultSerializer < ApplicationSerializer
|
||||||
:post,
|
:post,
|
||||||
:errors,
|
:errors,
|
||||||
:success,
|
:success,
|
||||||
:pending_count
|
:pending_count,
|
||||||
|
:reason
|
||||||
|
|
||||||
def post
|
def post
|
||||||
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
post_serializer = PostSerializer.new(object.post, scope: scope, root: false)
|
||||||
|
@ -33,6 +34,14 @@ class NewPostResultSerializer < ApplicationSerializer
|
||||||
!object.errors.empty?
|
!object.errors.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reason
|
||||||
|
object.reason
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_reason?
|
||||||
|
reason.present?
|
||||||
|
end
|
||||||
|
|
||||||
def action
|
def action
|
||||||
object.action
|
object.action
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,7 +60,7 @@ class NewPostManager
|
||||||
end
|
end
|
||||||
|
|
||||||
# Enqueue this post in a queue
|
# Enqueue this post in a queue
|
||||||
def enqueue(queue)
|
def enqueue(queue, reason=nil)
|
||||||
result = NewPostResult.new(:enqueued)
|
result = NewPostResult.new(:enqueued)
|
||||||
enqueuer = PostEnqueuer.new(@user, queue)
|
enqueuer = PostEnqueuer.new(@user, queue)
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ class NewPostManager
|
||||||
QueuedPost.broadcast_new! if post && post.errors.empty?
|
QueuedPost.broadcast_new! if post && post.errors.empty?
|
||||||
|
|
||||||
result.queued_post = post
|
result.queued_post = post
|
||||||
|
result.reason = reason if reason
|
||||||
result.check_errors_from(enqueuer)
|
result.check_errors_from(enqueuer)
|
||||||
result.pending_count = QueuedPost.new_posts.where(user_id: @user.id).count
|
result.pending_count = QueuedPost.new_posts.where(user_id: @user.id).count
|
||||||
result
|
result
|
||||||
|
|
|
@ -4,6 +4,8 @@ class NewPostResult
|
||||||
include HasErrors
|
include HasErrors
|
||||||
|
|
||||||
attr_reader :action
|
attr_reader :action
|
||||||
|
|
||||||
|
attr_accessor :reason
|
||||||
attr_accessor :post
|
attr_accessor :post
|
||||||
attr_accessor :queued_post
|
attr_accessor :queued_post
|
||||||
attr_accessor :pending_count
|
attr_accessor :pending_count
|
||||||
|
|
Loading…
Reference in New Issue
Block a user