mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FEATURE: staff option to unhide a post
This commit is contained in:
parent
e8522e839b
commit
0b13f6572f
10 changed files with 63 additions and 24 deletions
|
@ -397,6 +397,10 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
|
||||||
|
|
||||||
rebakePost: function (post) {
|
rebakePost: function (post) {
|
||||||
post.rebake();
|
post.rebake();
|
||||||
|
},
|
||||||
|
|
||||||
|
unhidePost: function (post) {
|
||||||
|
post.unhide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -512,30 +516,30 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
|
||||||
}
|
}
|
||||||
|
|
||||||
var postStream = topicController.get('postStream');
|
var postStream = topicController.get('postStream');
|
||||||
if (data.type === "revised" || data.type === "acted") {
|
switch (data.type) {
|
||||||
// TODO we could update less data for "acted"
|
case "revised":
|
||||||
// (only post actions)
|
case "acted":
|
||||||
postStream.triggerChangedPost(data.id, data.updated_at);
|
case "rebaked": {
|
||||||
return;
|
// TODO we could update less data for "acted" (only post actions)
|
||||||
|
postStream.triggerChangedPost(data.id, data.updated_at);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case "deleted": {
|
||||||
|
postStream.triggerDeletedPost(data.id, data.post_number);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case "recovered": {
|
||||||
|
postStream.triggerRecoveredPost(data.id, data.post_number);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case "created": {
|
||||||
|
postStream.triggerNewPostInStream(data.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
Em.Logger.warn("unknown topic bus message type", data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === "deleted") {
|
|
||||||
postStream.triggerDeletedPost(data.id, data.post_number);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === "recovered") {
|
|
||||||
postStream.triggerRecoveredPost(data.id, data.post_number);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.type === "created") {
|
|
||||||
postStream.triggerNewPostInStream(data.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// log a warning
|
|
||||||
Em.Logger.warn("unknown topic bus message type", data);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -404,6 +404,10 @@ Discourse.Post = Discourse.Model.extend({
|
||||||
|
|
||||||
rebake: function () {
|
rebake: function () {
|
||||||
return Discourse.ajax("/posts/" + this.get("id") + "/rebake", { type: "PUT" });
|
return Discourse.ajax("/posts/" + this.get("id") + "/rebake", { type: "PUT" });
|
||||||
|
},
|
||||||
|
|
||||||
|
unhide: function () {
|
||||||
|
return Discourse.ajax("/posts/" + this.get("id") + "/unhide", { type: "PUT" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -287,12 +287,16 @@ export default Discourse.View.extend({
|
||||||
var rebakePostIcon = '<i class="fa fa-cog"></i>',
|
var rebakePostIcon = '<i class="fa fa-cog"></i>',
|
||||||
rebakePostText = I18n.t('post.controls.rebake');
|
rebakePostText = I18n.t('post.controls.rebake');
|
||||||
|
|
||||||
|
var unhidePostIcon = '<i class="fa fa-eye"></i>',
|
||||||
|
unhidePostText = I18n.t('post.controls.unhide');
|
||||||
|
|
||||||
var html = '<div class="post-admin-menu">' +
|
var html = '<div class="post-admin-menu">' +
|
||||||
'<h3>' + I18n.t('admin_title') + '</h3>' +
|
'<h3>' + I18n.t('admin_title') + '</h3>' +
|
||||||
'<ul>' +
|
'<ul>' +
|
||||||
'<li class="btn btn-admin" data-action="toggleWiki">' + wikiIcon + wikiText + '</li>' +
|
'<li class="btn btn-admin" data-action="toggleWiki">' + wikiIcon + wikiText + '</li>' +
|
||||||
'<li class="btn btn-admin" data-action="togglePostType">' + postTypeIcon + postTypeText + '</li>' +
|
'<li class="btn btn-admin" data-action="togglePostType">' + postTypeIcon + postTypeText + '</li>' +
|
||||||
'<li class="btn btn-admin" data-action="rebakePost">' + rebakePostIcon + rebakePostText + '</li>' +
|
'<li class="btn btn-admin" data-action="rebakePost">' + rebakePostIcon + rebakePostText + '</li>' +
|
||||||
|
(post.hidden ? '<li class="btn btn-admin" data-action="unhidePost">' + unhidePostIcon + unhidePostText + '</li>' : '') +
|
||||||
'</ul>' +
|
'</ul>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
|
@ -317,6 +321,10 @@ export default Discourse.View.extend({
|
||||||
this.get("controller").send("rebakePost", this.get("post"));
|
this.get("controller").send("rebakePost", this.get("post"));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clickUnhidePost: function () {
|
||||||
|
this.get("controller").send("unhidePost", this.get("post"));
|
||||||
|
},
|
||||||
|
|
||||||
buttonForShowMoreActions: function() {
|
buttonForShowMoreActions: function() {
|
||||||
return new Button('showMoreActions', 'show_more', 'ellipsis-h');
|
return new Button('showMoreActions', 'show_more', 'ellipsis-h');
|
||||||
},
|
},
|
||||||
|
|
|
@ -162,4 +162,4 @@ kbd
|
||||||
padding: .1em .6em;
|
padding: .1em .6em;
|
||||||
|
|
||||||
* * { display: none; }
|
* * { display: none; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,16 @@ class PostsController < ApplicationController
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unhide
|
||||||
|
post = find_post_from_params
|
||||||
|
|
||||||
|
guardian.ensure_can_unhide!(post)
|
||||||
|
|
||||||
|
post.unhide!
|
||||||
|
|
||||||
|
render nothing: true
|
||||||
|
end
|
||||||
|
|
||||||
def flagged_posts
|
def flagged_posts
|
||||||
params.permit(:offset, :limit)
|
params.permit(:offset, :limit)
|
||||||
guardian.ensure_can_see_flagged_posts!
|
guardian.ensure_can_see_flagged_posts!
|
||||||
|
|
|
@ -293,6 +293,7 @@ class Post < ActiveRecord::Base
|
||||||
self.update_attributes(hidden: false, hidden_at: nil, hidden_reason_id: nil)
|
self.update_attributes(hidden: false, hidden_at: nil, hidden_reason_id: nil)
|
||||||
self.topic.update_attributes(visible: true)
|
self.topic.update_attributes(visible: true)
|
||||||
save(validate: false)
|
save(validate: false)
|
||||||
|
publish_change_to_clients!(:acted)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
|
@ -352,6 +353,8 @@ class Post < ActiveRecord::Base
|
||||||
# make sure we trigger the post process
|
# make sure we trigger the post process
|
||||||
trigger_post_process(true)
|
trigger_post_process(true)
|
||||||
|
|
||||||
|
publish_change_to_clients!(:rebaked)
|
||||||
|
|
||||||
new_cooked != old_cooked
|
new_cooked != old_cooked
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1112,6 +1112,7 @@ en:
|
||||||
convert_to_moderator: "Add Staff Color"
|
convert_to_moderator: "Add Staff Color"
|
||||||
revert_to_regular: "Remove Staff Color"
|
revert_to_regular: "Remove Staff Color"
|
||||||
rebake: "Rebuild HTML"
|
rebake: "Rebuild HTML"
|
||||||
|
unhide: "Unhide"
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
flag: 'Flag'
|
flag: 'Flag'
|
||||||
|
|
|
@ -265,6 +265,7 @@ Discourse::Application.routes.draw do
|
||||||
put "wiki"
|
put "wiki"
|
||||||
put "post_type"
|
put "post_type"
|
||||||
put "rebake"
|
put "rebake"
|
||||||
|
put "unhide"
|
||||||
get "replies"
|
get "replies"
|
||||||
get "revisions/:revision" => "posts#revisions"
|
get "revisions/:revision" => "posts#revisions"
|
||||||
put "recover"
|
put "recover"
|
||||||
|
|
|
@ -184,4 +184,8 @@ module PostGuardian
|
||||||
def can_see_deleted_posts?
|
def can_see_deleted_posts?
|
||||||
is_staff?
|
is_staff?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_unhide?(post)
|
||||||
|
post.try(:hidden) && is_staff?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -823,6 +823,8 @@ describe Post do
|
||||||
Post.exec_sql("UPDATE posts SET cooked = 'frogs' WHERE id = ?", post.id)
|
Post.exec_sql("UPDATE posts SET cooked = 'frogs' WHERE id = ?", post.id)
|
||||||
post.reload
|
post.reload
|
||||||
|
|
||||||
|
post.expects(:publish_change_to_clients!).with(:rebaked)
|
||||||
|
|
||||||
result = post.rebake!
|
result = post.rebake!
|
||||||
|
|
||||||
post.baked_at.should_not == first_baked
|
post.baked_at.should_not == first_baked
|
||||||
|
@ -857,6 +859,8 @@ describe Post do
|
||||||
|
|
||||||
post.hidden.should == true
|
post.hidden.should == true
|
||||||
|
|
||||||
|
post.expects(:publish_change_to_clients!).with(:acted)
|
||||||
|
|
||||||
post.unhide!
|
post.unhide!
|
||||||
post.reload
|
post.reload
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue