diff 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
line wrap: on
line diff
--- 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
         """