Mercurial > libervia-web
changeset 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 | 9054793ab60d |
children | ed6d8f7c6026 |
files | src/browser/libervia_main.py src/browser/sat_browser/blog.py |
diffstat | 2 files changed, 21 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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,))
--- 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 """