# HG changeset patch # User Goffi # Date 1423246988 -3600 # Node ID be2891462e63a4b1f60e4161204996c9b2c8ce42 # Parent 9054793ab60ddc3a8e957cc9460e79f6dc63b2d4 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. diff -r 9054793ab60d -r be2891462e63 src/browser/libervia_main.py --- a/src/browser/libervia_main.py Fri Feb 06 19:19:49 2015 +0100 +++ b/src/browser/libervia_main.py Fri Feb 06 19:23:08 2015 +0100 @@ -505,7 +505,7 @@ mblog_entry = blog.MicroblogItem(data) for widget in self.widgets.getWidgets(blog.MicroblogPanel): - self.addBlogEntry(widget, sender, _groups, mblog_entry) + widget.addEntryIfAccepted(sender, _groups, mblog_entry) if sender == self.whoami.bare: found = False @@ -533,24 +533,15 @@ self.mblog_cache.remove(entry) break - def addBlogEntry(self, mblog_panel, sender, _groups, mblog_entry): - """Check if an entry can go in MicroblogPanel and add to it - @param mblog_panel: MicroblogPanel instance - @param sender: jid of the entry sender - @param _groups: groups which can receive this entry - @param mblog_entry: panels.MicroblogItem instance""" - if mblog_entry.type == "comment" or mblog_panel.isJidAccepted(sender) or (_groups == None and self.whoami and sender == self.whoami.bare) \ - or (_groups and _groups.intersection(mblog_panel.accepted_groups)): - mblog_panel.addEntry(mblog_entry) - def FillMicroblogPanel(self, mblog_panel): """Fill a microblog panel with entries in cache + @param mblog_panel: MicroblogPanel instance """ #XXX: only our own entries are cached for cache_entry in self.mblog_cache: _groups, mblog_entry = cache_entry - self.addBlogEntry(mblog_panel, self.whoami.bare, *cache_entry) + mblog_panel.addEntryIfAccepted(self.whoami.bare, *cache_entry) def getEntityMBlog(self, entity): log.info("geting mblog for entity [%s]" % (entity,)) diff -r 9054793ab60d -r be2891462e63 src/browser/sat_browser/blog.py --- a/src/browser/sat_browser/blog.py Fri Feb 06 19:19:49 2015 +0100 +++ b/src/browser/sat_browser/blog.py Fri Feb 06 19:23:08 2015 +0100 @@ -427,8 +427,8 @@ (as an array) or None (for the meta group = "all groups") @return: the created MicroblogPanel """ - _items = item if isinstance(item, list) else ([] if item is None else [item]) - _type = 'ALL' if _items == [] else 'GROUP' + items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,)) + type_ = 'ALL' if items_ == () else 'GROUP' # XXX: pyjamas doesn't support use of cls directly _new_panel = MicroblogPanel(host, _items) host.FillMicroblogPanel(_new_panel) @@ -547,8 +547,23 @@ vpanel.insert(entry, idx) - def addEntry(self, data): + + def addEntryIfAccepted(self, sender, groups, mblog_entry): + """Check if an entry can go in MicroblogPanel and add to it + + @param sender: jid of the entry sender + @param groups: groups which can receive this entry + @param mblog_entry: panels.MicroblogItem instance + """ + if (mblog_entry.type == "comment" + or self.isJidAccepted(sender) + or (groups == None and sender == self.host.profiles[self.profile].whoami.bare) + or (groups and groups.intersection(self.accepted_groups))): + self.addEntry(mblog_entry) + + def addEntry(self, data, ignore_invalid=False): """Add an entry to the panel + @param data: dict containing the item data @return: the added entry, or None """