From a10064c2053e3a5266a14f08d51a5b539fd5bdf5 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 2 Jan 2019 17:46:01 -0600 Subject: [PATCH] If user is not allowed to post in someone's wall, hide the post button --- src/controller/buffers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/controller/buffers.py b/src/controller/buffers.py index 6fbc2b7..16ea7b4 100644 --- a/src/controller/buffers.py +++ b/src/controller/buffers.py @@ -391,6 +391,16 @@ class feedBuffer(baseBuffer): super(feedBuffer, self).__init__(*args, **kwargs) self.user_key = "from_id" self.post_key = "id" + self.can_post = True + self.can_write_private_message = True + # if this is an user timeline we must check permissions to hide buttons when needed. + if "owner_id" in self.kwargs: + permissions = self.session.vk.client.users.get(user_ids=self.kwargs["owner_id"], fields="can_post, can_see_all_posts, can_write_private_message") + self.can_post = permissions[0]["can_post"] + self.can_see_all_posts = permissions[0]["can_see_all_posts"] + self.can_write_private_message = permissions[0]["can_write_private_message"] + if self.can_post == False: + self.tab.post.Enable(False) def post(self, *args, **kwargs): """ Create a post in the wall for the specified user