This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch db/8540 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 114c7bea111a2caf5151143a2ffa72698fedf472 Author: Dave Brondsema <dbronds...@slashdotmedia.com> AuthorDate: Thu Mar 28 14:22:54 2024 -0400 [#8540] wiki pages' recent sort by mod_date; simplify code --- ForgeWiki/forgewiki/templates/wiki/browse.html | 6 +----- ForgeWiki/forgewiki/wiki_main.py | 16 ++++------------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/ForgeWiki/forgewiki/templates/wiki/browse.html b/ForgeWiki/forgewiki/templates/wiki/browse.html index c384f0f1c..1bb776d92 100644 --- a/ForgeWiki/forgewiki/templates/wiki/browse.html +++ b/ForgeWiki/forgewiki/templates/wiki/browse.html @@ -52,11 +52,7 @@ {% else %} <td></td> {% endif %} - {% if 'updated' in page %} - <td>{{abbr_date(page['updated'])}}</td> - {% else %} - <td></td> - {% endif %} + <td>{{abbr_date(page['mod_date'])}}</td> </tr> {% endfor %} </tbody> diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py index bac4d36da..8876cd8eb 100644 --- a/ForgeWiki/forgewiki/wiki_main.py +++ b/ForgeWiki/forgewiki/wiki_main.py @@ -477,24 +477,16 @@ class RootController(BaseController, DispatchIndex, FeedController): q = WM.Page.query.find(criteria) if sort == 'alpha': q = q.sort('title') + elif sort == 'recent': + q = q.sort('mod_date', -1) count = q.count() q = q.skip(start).limit(int(limit)) for page in q: recent_edit = page.history().first() - p = dict(title=page.title, url=page.url(), deleted=page.deleted) + p = dict(title=page.title, url=page.url(), deleted=page.deleted, mod_date=page.mod_date) if recent_edit: - p['updated'] = recent_edit.timestamp - p['user_label'] = recent_edit.author.display_name p['user_name'] = recent_edit.author.username - pages.append(p) - else: - if sort == 'recent': - uv_pages.append(p) - else: - pages.append(p) - if sort == 'recent': - pages.sort(reverse=True, key=lambda x: (x['updated'])) - pages = pages + uv_pages + pages.append(p) h1_text = f"{c.project.name} {c.app.config.options.mount_label} - Browse Pages" return dict( pages=pages, can_delete=can_delete, show_deleted=show_deleted,