comparison src/browser/sat_browser/blog.py @ 785:103f0f01ba54

browser side (blog): fixed entries and comments ordering
author Goffi <goffi@goffi.org>
date Tue, 01 Dec 2015 14:26:53 +0100
parents 08c6e097ff5d
children c500bdb0c216
comparison
equal deleted inserted replaced
784:f3cd261ea12f 785:103f0f01ba54
190 self.comments_panel.addStyleName('subPanel') 190 self.comments_panel.addStyleName('subPanel')
191 self.add(self.comments_panel) 191 self.add(self.comments_panel)
192 192
193 def setEditable(self, editable=True): 193 def setEditable(self, editable=True):
194 """Toggle the bubble between display and edit mode. 194 """Toggle the bubble between display and edit mode.
195 195
196 @param editable (bool) 196 @param editable (bool)
197 """ 197 """
198 self.editable = editable 198 self.editable = editable
199 self.bubble.edit(self.editable) 199 self.bubble.edit(self.editable)
200 self.updateIconsAndButtons() 200 self.updateIconsAndButtons()
374 374
375 def update(self, entry=None): 375 def update(self, entry=None):
376 """Update comments""" 376 """Update comments"""
377 self._createCommentsPanel() 377 self._createCommentsPanel()
378 self.entries.sort(key=lambda entry: entry.item.published, reverse=True) 378 self.entries.sort(key=lambda entry: entry.item.published, reverse=True)
379 idx = 0 379 for idx, entry in enumerate(self.entries):
380 for entry in self.entries:
381 if not entry.displayed: 380 if not entry.displayed:
382 self.comments_panel.insert(entry, idx) 381 self.comments_panel.insert(entry, idx)
383 entry.displayed = True 382 entry.displayed = True
384 idx += 1
385 383
386 def delete(self): 384 def delete(self):
387 quick_blog.Entry.delete(self) 385 quick_blog.Entry.delete(self)
388 386
389 # _current comment is specific to libervia, we remove it 387 # _current comment is specific to libervia, we remove it
434 return u"Blog Widget [targets: {}, profile: {}]".format(", ".join(self.targets) if self.targets else "meta blog", self.profile) 432 return u"Blog Widget [targets: {}, profile: {}]".format(", ".join(self.targets) if self.targets else "meta blog", self.profile)
435 433
436 def update(self): 434 def update(self):
437 self.entries.sort(key=lambda entry: entry.item.published, reverse=True) 435 self.entries.sort(key=lambda entry: entry.item.published, reverse=True)
438 436
439 idx = 0 437 start_idx = 0
440 if self._first_entry is not None: 438 if self._first_entry is not None:
441 idx += 1 439 start_idx = 1
442 if not self._first_entry.displayed: 440 if not self._first_entry.displayed:
443 self.vpanel.insert(self._first_entry, 0) 441 self.vpanel.insert(self._first_entry, 0)
444 self._first_entry.displayed = True 442 self._first_entry.displayed = True
445 443
444 # XXX: enumerate is buggued in pyjamas (start is not used)
445 # we have to use idx
446 idx = start_idx
446 for entry in self.entries: 447 for entry in self.entries:
447 if not entry.displayed: 448 if not entry.displayed:
448 self.vpanel.insert(entry, idx) 449 self.vpanel.insert(entry, idx)
449 entry.displayed = True 450 entry.displayed = True
450 idx += 1 451 idx += 1
451 452
452 # def onDelete(self): 453 # def onDelete(self):
453 # quick_widgets.QuickWidget.onDelete(self) 454 # quick_widgets.QuickWidget.onDelete(self)
454 # self.host.removeListener('avatar', self.avatarListener) 455 # self.host.removeListener('avatar', self.avatarListener)
455 456