# HG changeset patch # User souliane # Date 1387457807 -3600 # Node ID 44b46db7dfefea6f913afdc2c309c72c6f777346 # Parent 52b1afd7ac3fb68d7df24d0040654ea99f9cc04f browser_side (groupblog): order items using "published" instead of "updated" diff -r 52b1afd7ac3f -r 44b46db7dfef browser_side/panels.py --- a/browser_side/panels.py Wed Dec 18 15:39:13 2013 +0100 +++ b/browser_side/panels.py Thu Dec 19 13:56:47 2013 +0100 @@ -324,7 +324,11 @@ self.content = data['content'] self.xhtml = data.get('xhtml') self.author = data['author'] - self.timestamp = float(data.get('timestamp', 0)) # XXX: int doesn't work here + self.updated = float(data.get('updated', 0)) # XXX: int doesn't work here + try: + self.published = float(data['published']) # XXX: int doesn't work here + except KeyError: + self.published = self.updated self.comments = data.get('comments', False) if self.comments: try: @@ -356,8 +360,8 @@ self.entry = mblog_entry self.author = mblog_entry.author - self.timestamp = mblog_entry.timestamp - _datetime = datetime.fromtimestamp(mblog_entry.timestamp) + self.updated = mblog_entry.updated + self.published = mblog_entry.published self.comments = mblog_entry.comments self.pub_data = (mblog_entry.hash[0], mblog_entry.hash[1], mblog_entry.id) @@ -365,11 +369,18 @@ self.panel = FlowPanel() self.panel.setStyleName('mb_entry') + update_text = u" — ✍ " + "%s" % datetime.fromtimestamp(self.updated) header = HTMLPanel("""
- - on - -
""" % {'author': html_sanitize(self.author), 'timestamp': _datetime}) + %(author)s on + %(published)s%(updated)s + """ % {'author': html_sanitize(self.author), + 'published': datetime.fromtimestamp(self.published), + 'updated': update_text if self.published != self.updated else '' + } + ) + + + self.panel.add(header) if self.author == blog_panel.host.whoami.bare: @@ -452,8 +463,10 @@ if cancel or new_text == self.editable_content[0] or new_text == "": return self.editable_content[0] = new_text - self._blog_panel.host.bridge.call('updateMblog', None, self.pub_data, self.comments, new_text, - {'rich': new_text} if self.entry.xhtml else {}) + extra = {'published': str(self.published)} + if self.entry.xhtml: + extra.update({'rich': new_text}) + self._blog_panel.host.bridge.call('updateMblog', None, self.pub_data, self.comments, new_text, extra) def _update(self): """Change the bubble to an editbox""" @@ -643,10 +656,10 @@ idx += 1 continue if reverse: - if child.timestamp < entry.timestamp: + if child.published < entry.published: break else: - if child.timestamp > entry.timestamp: + if child.published > entry.published: break idx += 1