FEATURE: remove "liking" on OP for topics with voting

This commit is contained in:
Sam 2017-03-03 16:58:07 -05:00
parent 4e5eb31d33
commit 619737d209
3 changed files with 25 additions and 1 deletions

View File

@ -3,6 +3,13 @@ import Category from 'discourse/models/category';
import { withPluginApi } from 'discourse/lib/plugin-api';
function initialize(api) {
api.addPostClassesCallback((post) => {
if (post.post_number === 1 && post.can_vote) {
return ["voting-post"];
}
});
api.includePostAttributes('can_vote');
api.addTagsHtmlCallback((topic) => {
if (!topic.can_vote) { return; }
@ -33,7 +40,7 @@ export default {
before: 'inject-discourse-objects',
initialize(container) {
withPluginApi('0.8.3', api => {
withPluginApi('0.8.4', api => {
initialize(api, container);
});

View File

@ -122,3 +122,7 @@
.upgrade-answer i{
margin: 0px 5px 0px 0px;
}
.topic-post.voting-post {
button.like-count, button.toggle-like { display: none; }
}

View File

@ -15,6 +15,19 @@ Discourse.anonymous_filters.push(:votes)
after_initialize do
require_dependency 'post_serializer'
class ::PostSerializer
attributes :can_vote
def include_can_vote?
object.post_number == 1 && object.topic && object.topic.can_vote?
end
def can_vote
true
end
end
require_dependency 'topic_view_serializer'
class ::TopicViewSerializer
attributes :can_vote, :vote_count, :user_voted