Added loading of group members and actions on them.

This commit is contained in:
Manuel Cortez 2021-04-23 14:39:08 -05:00
parent b86bad024e
commit 783d54b55f
5 changed files with 31 additions and 4 deletions

View File

@ -4,6 +4,7 @@
### new additions
* Now socializer can load the list of members for a community. You have to use the context menu in the community in order to load all members. For community administrators and moderators, it will display also a new buffer with invites that have been sent to the group. You can use the context menu in those buffers to perform common actions to those user. Take into account, though, that available actions from those buffers depend in the focused user's privacy settings.
* Added an actions button that allows you to perform several tasks from the parts of the application where it appears. For now, the action button is shown in any displayed post or repost, and also in chat messages. When pressed, it opens a menu from where you can translate texts or do spelling correction on the message.
* It is now possible to read an article from a wall post. The article will be opened in a new dialog. This might work better in countries where VK is blocked as users no longer need to open the web browser. Unfortunately, as articles are mainly undocumented in the API, it is not possible to perform other actions besides reading them from Socializer.
* the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore.

View File

@ -12,3 +12,4 @@ from .videoAlbum import videoAlbumBuffer as videoAlbum
from .chat import chatBuffer
from .people import peopleBuffer
from .friendRequests import friendRequestsBuffer as requestsBuffer
from .communityPeople import communityPeopleBuffer

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
import logging
import wx
import widgetUtils
from .people import peopleBuffer
log = logging.getLogger("controller.buffers.communityPeople")
class communityPeopleBuffer(peopleBuffer):
def get_menu(self, *args, **kwargs):
user = self.get_post()
m = wx.Menu()
if user.get("can_post") == True:
can_post = m.Append(wx.NewId(), _("&Post on user's wall"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.post, menuitem=can_post)
if user.get("can_write_private_message") == True:
can_write_message = m.Append(wx.Id(), _("Send message"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=can_write_message)
profile = m.Append(wx.NewId(), _("View profile"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=profile)
timeline = m.Append(wx.NewId(), _("Open timeline"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=timeline)
open_in_browser = m.Append(wx.NewId(), _("Open in vk.com"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=open_in_browser)
return m

View File

@ -67,7 +67,6 @@ class peopleBuffer(wallBuffer):
self.tab.new_chat.Enable(True)
else:
self.tab.new_chat.Enable(False)
print(post)
if ("last_seen" in post) == False: return
original_date = arrow.get(post["last_seen"]["time"])
now = arrow.now()

View File

@ -1081,10 +1081,10 @@ class Controller(object):
# ToDo: This needs testing in groups where the current user is not a full admin (such as moderator or editor).
if (self.session.db["group_info"][current_buffer.group_id].get("is_admin") != None and self.session.db["group_info"][current_buffer.group_id].get("is_admin") == 1):
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("People"), parent_tab=current_buffer.tab.name, kwargs=dict(parent=self.window.tb, name=current_buffer.tab.name+"_people"))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Members"), parent_tab=current_buffer.name+"_people", get_items=True, kwargs=dict(parent=self.window.tb, name=current_buffer.name+"_members", composefunc="render_person", session=self.session, endpoint="getMembers", parent_endpoint="groups", count=1000, order=sorting, fields="uid, first_name, last_name, last_seen, can_post", group_id=-1*current_buffer.kwargs["owner_id"]))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Invited users"), parent_tab=current_buffer.name+"_people", get_items=True, kwargs=dict(parent=self.window.tb, name=current_buffer.name+"_invites", composefunc="render_person", session=self.session, endpoint="getInvitedUsers", parent_endpoint="groups", count=1000, fields="first_name, last_name, last_seen, can_post, can_write_private_message", group_id=-1*current_buffer.kwargs["owner_id"]))
pub.sendMessage("create_buffer", buffer_type="communityPeopleBuffer", buffer_title=_("Members"), parent_tab=current_buffer.name+"_people", get_items=True, kwargs=dict(parent=self.window.tb, name=current_buffer.name+"_members", composefunc="render_person", session=self.session, endpoint="getMembers", parent_endpoint="groups", count=1000, order=sorting, fields="uid, first_name, last_name, last_seen, can_post", group_id=-1*current_buffer.kwargs["owner_id"]))
pub.sendMessage("create_buffer", buffer_type="communityPeopleBuffer", buffer_title=_("Invited users"), parent_tab=current_buffer.name+"_people", get_items=True, kwargs=dict(parent=self.window.tb, name=current_buffer.name+"_invites", composefunc="render_person", session=self.session, endpoint="getInvitedUsers", parent_endpoint="groups", count=1000, fields="first_name, last_name, last_seen, can_post, can_write_private_message", group_id=-1*current_buffer.kwargs["owner_id"]))
else: # Create this for non administrators.
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Members"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=current_buffer.name+"_members", composefunc="render_person", session=self.session, endpoint="getMembers", parent_endpoint="groups", count=1000, order=sorting, fields="uid, first_name, last_name, last_seen, can_post, can_write_private_message", group_id=-1*current_buffer.kwargs["owner_id"]))
pub.sendMessage("create_buffer", buffer_type="communityPeopleBuffer", buffer_title=_("Members"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=current_buffer.name+"_members", composefunc="render_person", session=self.session, endpoint="getMembers", parent_endpoint="groups", count=1000, order=sorting, fields="uid, first_name, last_name, last_seen, can_post, can_write_private_message", group_id=-1*current_buffer.kwargs["owner_id"]))
def load_community_documents(self, *args, **kwargs):
current_buffer = self.get_current_buffer()