comparison src/browser/libervia_main.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 a5019e62c3e9
children 7af8f4ab3675
comparison
equal deleted inserted replaced
596:9054793ab60d 597:be2891462e63
503 else: 503 else:
504 _groups = None 504 _groups = None
505 mblog_entry = blog.MicroblogItem(data) 505 mblog_entry = blog.MicroblogItem(data)
506 506
507 for widget in self.widgets.getWidgets(blog.MicroblogPanel): 507 for widget in self.widgets.getWidgets(blog.MicroblogPanel):
508 self.addBlogEntry(widget, sender, _groups, mblog_entry) 508 widget.addEntryIfAccepted(sender, _groups, mblog_entry)
509 509
510 if sender == self.whoami.bare: 510 if sender == self.whoami.bare:
511 found = False 511 found = False
512 for index in xrange(0, len(self.mblog_cache)): 512 for index in xrange(0, len(self.mblog_cache)):
513 entry = self.mblog_cache[index] 513 entry = self.mblog_cache[index]
531 entry = self.mblog_cache[index] 531 entry = self.mblog_cache[index]
532 if entry[1].id == data['id']: 532 if entry[1].id == data['id']:
533 self.mblog_cache.remove(entry) 533 self.mblog_cache.remove(entry)
534 break 534 break
535 535
536 def addBlogEntry(self, mblog_panel, sender, _groups, mblog_entry):
537 """Check if an entry can go in MicroblogPanel and add to it
538 @param mblog_panel: MicroblogPanel instance
539 @param sender: jid of the entry sender
540 @param _groups: groups which can receive this entry
541 @param mblog_entry: panels.MicroblogItem instance"""
542 if mblog_entry.type == "comment" or mblog_panel.isJidAccepted(sender) or (_groups == None and self.whoami and sender == self.whoami.bare) \
543 or (_groups and _groups.intersection(mblog_panel.accepted_groups)):
544 mblog_panel.addEntry(mblog_entry)
545
546 def FillMicroblogPanel(self, mblog_panel): 536 def FillMicroblogPanel(self, mblog_panel):
547 """Fill a microblog panel with entries in cache 537 """Fill a microblog panel with entries in cache
538
548 @param mblog_panel: MicroblogPanel instance 539 @param mblog_panel: MicroblogPanel instance
549 """ 540 """
550 #XXX: only our own entries are cached 541 #XXX: only our own entries are cached
551 for cache_entry in self.mblog_cache: 542 for cache_entry in self.mblog_cache:
552 _groups, mblog_entry = cache_entry 543 _groups, mblog_entry = cache_entry
553 self.addBlogEntry(mblog_panel, self.whoami.bare, *cache_entry) 544 mblog_panel.addEntryIfAccepted(self.whoami.bare, *cache_entry)
554 545
555 def getEntityMBlog(self, entity): 546 def getEntityMBlog(self, entity):
556 log.info("geting mblog for entity [%s]" % (entity,)) 547 log.info("geting mblog for entity [%s]" % (entity,))
557 for lib_wid in self.libervia_widgets: 548 for lib_wid in self.libervia_widgets:
558 if isinstance(lib_wid, panels.MicroblogPanel): 549 if isinstance(lib_wid, panels.MicroblogPanel):