Mercurial > libervia-web
changeset 651:2df91d0308ac frontends_multi_profiles
browser_side, server_side: MicroblogPanel.onGroupDrop and bridge method getMassiveLastMBlogs now only accepts the publishers as a set of unicode (no more None value or single unicode).
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 27 Feb 2015 01:08:36 +0100 |
parents | 7e3cdc39c3e7 |
children | 0262fee86375 |
files | src/browser/libervia_main.py src/browser/sat_browser/blog.py src/browser/sat_browser/contact_list.py src/server/server.py |
diffstat | 4 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/libervia_main.py Fri Feb 27 00:56:08 2015 +0100 +++ b/src/browser/libervia_main.py Fri Feb 27 01:08:36 2015 +0100 @@ -348,12 +348,12 @@ # we fill the panels already here for wid in self.widgets.getWidgets(blog.MicroblogPanel): if wid.accept_all(): - self.bridge.getMassiveLastMblogs('ALL', [], 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) + self.bridge.getMassiveLastMblogs('ALL', (), 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) else: self.bridge.getMassiveLastMblogs('GROUP', wid.accepted_groups, 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) #we ask for our own microblogs: - self.bridge.getMassiveLastMblogs('JID', [unicode(self.whoami.bare)], 10, profile=C.PROF_KEY_NONE, callback=self._ownBlogsFills) + self.bridge.getMassiveLastMblogs('JID', (unicode(self.whoami.bare),), 10, profile=C.PROF_KEY_NONE, callback=self._ownBlogsFills) # initialize plugins which waited for the connection to be done for plugin in self.plugins.values(): @@ -562,7 +562,7 @@ for lib_wid in self.libervia_widgets: if isinstance(lib_wid, blog.MicroblogPanel): if lib_wid.isJidAccepted(entity): - self.bridge.call('getMassiveLastMblogs', lib_wid.massiveInsert, 'JID', [entity], 10) + self.bridge.call('getMassiveLastMblogs', lib_wid.massiveInsert, 'JID', (entity,), 10) # def getLiberviaWidget(self, class_, entity, ignoreOtherTabs=True): # """Get the corresponding panel if it exists.
--- a/src/browser/sat_browser/blog.py Fri Feb 27 00:56:08 2015 +0100 +++ b/src/browser/sat_browser/blog.py Fri Feb 27 01:08:36 2015 +0100 @@ -437,20 +437,18 @@ return first if first.empty else None @staticmethod - def onGroupDrop(host, item): - """Generic panel creation for one, several or all groups (meta). + def onGroupDrop(host, targets): + """Create a microblog panel for one, several or all contact groups. @param host (SatWebFrontend): the SatWebFrontend instance - @param item: single group as a string, list of groups - (as an array) or None (for the meta group = "all groups") + @param targets (tuple(unicode)): tuple of groups (empty for "all groups") @return: the created MicroblogPanel """ - items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,)) - type_ = 'ALL' if items_ == () else 'GROUP' + type_ = 'ALL' if not targets else 'GROUP' # XXX: pyjamas doesn't support use of cls directly - widget = host.displayWidget(MicroblogPanel, items_, dropped=True) + widget = host.displayWidget(MicroblogPanel, targets, dropped=True) host.FillMicroblogPanel(widget) - host.bridge.getMassiveLastMblogs(type_, items_, 10, profile=C.PROF_KEY_NONE, callback=widget.massiveInsert) + host.bridge.getMassiveLastMblogs(type_, targets, 10, profile=C.PROF_KEY_NONE, callback=widget.massiveInsert) widget.refresh() # FIXME: needed ? return widget @@ -735,7 +733,7 @@ return False -libervia_widget.LiberviaWidget.addDropKey("GROUP", MicroblogPanel.onGroupDrop) +libervia_widget.LiberviaWidget.addDropKey("GROUP", lambda host, item: MicroblogPanel.onGroupDrop(host, (item,))) # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group -libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, None)) +libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, ()))
--- a/src/browser/sat_browser/contact_list.py Fri Feb 27 00:56:08 2015 +0100 +++ b/src/browser/sat_browser/contact_list.py Fri Feb 27 01:08:36 2015 +0100 @@ -85,7 +85,7 @@ self.addClickListener(self) def onClick(self, sender): - self.host.displayWidget(blog.MicroblogPanel, self.group) + self.host.displayWidget(blog.MicroblogPanel, (self.group,)) class GroupPanel(VerticalPanel): @@ -171,7 +171,7 @@ self.addClickListener(self) def onClick(self, sender): - self.host.displayWidget(blog.MicroblogPanel, None) + self.host.displayWidget(blog.MicroblogPanel, ()) class ContactList(SimplePanel, QuickContactList):
--- a/src/server/server.py Fri Feb 27 00:56:08 2015 +0100 +++ b/src/server/server.py Fri Feb 27 01:08:36 2015 +0100 @@ -325,15 +325,19 @@ d = self.asyncBridgeCall("getLastGroupBlogs", publisher_jid, max_item, profile) return d - def jsonrpc_getMassiveLastMblogs(self, publishers_type, publishers_list, max_item): + def jsonrpc_getMassiveLastMblogs(self, publishers_type, publishers, max_item): """Get lasts microblogs posted by several contacts at once - @param publishers_type: one of "ALL", "GROUP", "JID" - @param publishers_list: list of publishers type (empty list of all, list of groups or list of jids) - @param max_item: number of items to ask - @return: dictionary key=publisher's jid, value=list of microblog data (dict)""" + + @param publishers_type (unicode): one of "ALL", "GROUP", "JID" + @param publishers (tuple(unicode)): tuple of publishers (empty list for all, list of groups or list of jids) + @param max_item (int): number of items to ask + @return: dict{unicode: list[dict]) + key: publisher's jid + value: list of microblog data (dict) + """ profile = ISATSession(self.session).profile - d = self.asyncBridgeCall("getMassiveLastGroupBlogs", publishers_type, publishers_list, max_item, profile) - self.sat_host.bridge.massiveSubscribeGroupBlogs(publishers_type, publishers_list, profile) + d = self.asyncBridgeCall("getMassiveLastGroupBlogs", publishers_type, publishers, max_item, profile) + self.sat_host.bridge.massiveSubscribeGroupBlogs(publishers_type, publishers, profile) return d def jsonrpc_getMblogComments(self, service, node):