Display topic post: It is possible to like or dislike a topic comment when displaying it individually

This commit is contained in:
Manuel Cortez 2019-08-22 09:22:16 -05:00
parent 98b85435ac
commit 52e55a24fa
2 changed files with 19 additions and 1 deletions

View File

@ -138,6 +138,7 @@ class displayTopicPresenter(basePost.displayPostPresenter):
def show_comment(self, comment_index): def show_comment(self, comment_index):
c = self.comments["items"][comment_index] c = self.comments["items"][comment_index]
c["post_id"] = self.post["id"] c["post_id"] = self.post["id"]
c["group_id"] = -1*self.group_id
a = displayTopicCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment()) a = displayTopicCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
def load_more_comments(self): def load_more_comments(self):

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging import logging
import output
from sessionmanager import renderers, utils # We'll use some functions from there from sessionmanager import renderers, utils # We'll use some functions from there
from presenters import base from presenters import base
from presenters.createPosts.basePost import createPostPresenter from presenters.createPosts.basePost import createPostPresenter
@ -26,3 +27,19 @@ class displayTopicCommentPresenter(comment.displayCommentPresenter):
self.check_image_load() self.check_image_load()
self.send_message("disable_control", control="reply") self.send_message("disable_control", control="reply")
self.send_message("disable_control", control="comments") self.send_message("disable_control", control="comments")
def post_like(self):
id = self.post["id"]
if self.post["likes"]["user_likes"] == 1:
l = self.session.vk.client.likes.delete(owner_id=self.post["group_id"], item_id=id, type="topic_comment")
output.speak(_("You don't like this"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 2
self.send_message("set_label", control="like", label=_("&Like"))
else:
l = self.session.vk.client.likes.add(owner_id=self.post["group_id"], item_id=id, type="topic_comment")
output.speak(_("You liked this"))
self.send_message("set_label", control="like", label=_("&Dislike"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 1
self.get_likes()