comparison src/browser/sat_browser/blog.py @ 597:be2891462e63 frontends_multi_profiles

browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
author Goffi <goffi@goffi.org>
date Fri, 06 Feb 2015 19:23:08 +0100
parents d78126d82ca0
children ed6d8f7c6026
comparison
equal deleted inserted replaced
596:9054793ab60d 597:be2891462e63
425 @parem host: the SatWebFrontend instance 425 @parem host: the SatWebFrontend instance
426 @param item: single group as a string, list of groups 426 @param item: single group as a string, list of groups
427 (as an array) or None (for the meta group = "all groups") 427 (as an array) or None (for the meta group = "all groups")
428 @return: the created MicroblogPanel 428 @return: the created MicroblogPanel
429 """ 429 """
430 _items = item if isinstance(item, list) else ([] if item is None else [item]) 430 items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,))
431 _type = 'ALL' if _items == [] else 'GROUP' 431 type_ = 'ALL' if items_ == () else 'GROUP'
432 # XXX: pyjamas doesn't support use of cls directly 432 # XXX: pyjamas doesn't support use of cls directly
433 _new_panel = MicroblogPanel(host, _items) 433 _new_panel = MicroblogPanel(host, _items)
434 host.FillMicroblogPanel(_new_panel) 434 host.FillMicroblogPanel(_new_panel)
435 host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, _type, _items, 10) 435 host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, _type, _items, 10)
436 host.setSelected(_new_panel) 436 host.setSelected(_new_panel)
545 break 545 break
546 idx += 1 546 idx += 1
547 547
548 vpanel.insert(entry, idx) 548 vpanel.insert(entry, idx)
549 549
550 def addEntry(self, data): 550
551 def addEntryIfAccepted(self, sender, groups, mblog_entry):
552 """Check if an entry can go in MicroblogPanel and add to it
553
554 @param sender: jid of the entry sender
555 @param groups: groups which can receive this entry
556 @param mblog_entry: panels.MicroblogItem instance
557 """
558 if (mblog_entry.type == "comment"
559 or self.isJidAccepted(sender)
560 or (groups == None and sender == self.host.profiles[self.profile].whoami.bare)
561 or (groups and groups.intersection(self.accepted_groups))):
562 self.addEntry(mblog_entry)
563
564 def addEntry(self, data, ignore_invalid=False):
551 """Add an entry to the panel 565 """Add an entry to the panel
566
552 @param data: dict containing the item data 567 @param data: dict containing the item data
553 @return: the added entry, or None 568 @return: the added entry, or None
554 """ 569 """
555 _entry = MicroblogEntry(self, data) 570 _entry = MicroblogEntry(self, data)
556 if _entry.type == "comment": 571 if _entry.type == "comment":