comparison src/browser/sat_browser/blog.py @ 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 6d3142b782c3
children 0262fee86375
comparison
equal deleted inserted replaced
650:7e3cdc39c3e7 651:2df91d0308ac
435 return None 435 return None
436 assert(first.type == 'main_item') 436 assert(first.type == 'main_item')
437 return first if first.empty else None 437 return first if first.empty else None
438 438
439 @staticmethod 439 @staticmethod
440 def onGroupDrop(host, item): 440 def onGroupDrop(host, targets):
441 """Generic panel creation for one, several or all groups (meta). 441 """Create a microblog panel for one, several or all contact groups.
442 442
443 @param host (SatWebFrontend): the SatWebFrontend instance 443 @param host (SatWebFrontend): the SatWebFrontend instance
444 @param item: single group as a string, list of groups 444 @param targets (tuple(unicode)): tuple of groups (empty for "all groups")
445 (as an array) or None (for the meta group = "all groups")
446 @return: the created MicroblogPanel 445 @return: the created MicroblogPanel
447 """ 446 """
448 items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,)) 447 type_ = 'ALL' if not targets else 'GROUP'
449 type_ = 'ALL' if items_ == () else 'GROUP'
450 # XXX: pyjamas doesn't support use of cls directly 448 # XXX: pyjamas doesn't support use of cls directly
451 widget = host.displayWidget(MicroblogPanel, items_, dropped=True) 449 widget = host.displayWidget(MicroblogPanel, targets, dropped=True)
452 host.FillMicroblogPanel(widget) 450 host.FillMicroblogPanel(widget)
453 host.bridge.getMassiveLastMblogs(type_, items_, 10, profile=C.PROF_KEY_NONE, callback=widget.massiveInsert) 451 host.bridge.getMassiveLastMblogs(type_, targets, 10, profile=C.PROF_KEY_NONE, callback=widget.massiveInsert)
454 widget.refresh() # FIXME: needed ? 452 widget.refresh() # FIXME: needed ?
455 return widget 453 return widget
456 454
457 @property 455 @property
458 def accepted_groups(self): 456 def accepted_groups(self):
733 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group): 731 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group):
734 return True 732 return True
735 return False 733 return False
736 734
737 735
738 libervia_widget.LiberviaWidget.addDropKey("GROUP", MicroblogPanel.onGroupDrop) 736 libervia_widget.LiberviaWidget.addDropKey("GROUP", lambda host, item: MicroblogPanel.onGroupDrop(host, (item,)))
739 737
740 # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group 738 # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group
741 libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, None)) 739 libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, ()))