Mercurial > libervia-web
changeset 809:c500bdb0c216
browser (blog): fixed comments ordering
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 18 Dec 2015 19:37:13 +0100 |
parents | 9e1e6d5241f9 |
children | 3905bc24eb17 |
files | src/browser/sat_browser/blog.py |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/sat_browser/blog.py Tue Dec 15 20:04:03 2015 +0100 +++ b/src/browser/sat_browser/blog.py Fri Dec 18 19:37:13 2015 +0100 @@ -333,7 +333,7 @@ if self._current_comment is None: if not self.item.comments_service or not self.item.comments_node: log.warning("Invalid service and node for comments, can't create a comment") - self._current_comment = self.addEntry(editable=True, service=self.item.comments_service, node=self.item.comments_node) + self._current_comment = self.addEntry(editable=True, service=self.item.comments_service, node=self.item.comments_node, edit_entry=True) self.blog.setSelectedEntry(self._current_comment, True) def _changeMode(self, original_content, text): @@ -375,8 +375,10 @@ def update(self, entry=None): """Update comments""" self._createCommentsPanel() - self.entries.sort(key=lambda entry: entry.item.published, reverse=True) - for idx, entry in enumerate(self.entries): + self.entries.sort(key=lambda entry: entry.item.published) + # we put edit_entry at the end + edit_entry = [] if self.edit_entry is None else [self.edit_entry] + for idx, entry in enumerate(self.entries + edit_entry): if not entry.displayed: self.comments_panel.insert(entry, idx) entry.displayed = True @@ -417,7 +419,7 @@ self.setWidget(self.vpanel) if ((self._targets_type == C.ALL and self.host.mblog_available) or (self._targets_type == C.GROUP and self.host.groupblog_available)): - self.addEntry(editable=True, first=True) + self.addEntry(editable=True, edit_entry=True) self.getAll() @@ -435,11 +437,11 @@ self.entries.sort(key=lambda entry: entry.item.published, reverse=True) start_idx = 0 - if self._first_entry is not None: + if self.edit_entry is not None: start_idx = 1 - if not self._first_entry.displayed: - self.vpanel.insert(self._first_entry, 0) - self._first_entry.displayed = True + if not self.edit_entry.displayed: + self.vpanel.insert(self.edit_entry, 0) + self.edit_entry.displayed = True # XXX: enumerate is buggued in pyjamas (start is not used) # we have to use idx