From 483ced5f74d05d6d282d98c9cb29d24dd3f228d4 Mon Sep 17 00:00:00 2001 From: James Polley Date: Sun, 13 Jul 2014 17:19:00 +1000 Subject: [PATCH] Don't hide inactive projects when listing all. If the user is viewing only their subscribed projects, it makes sense to let them toggle between seeing all projects and only those with unreviewed reviews. When they've chosen to list unsubscribed projects as well, this seems to make less sense. The unsubscribed projects will all have no unreviewed reviews, so no unsubscribed projects would ever be listed. In effect, this means that to list all projects the user now has to press two keys (l,a) rather than one (l). This commit ignores the active_only flag when listing unsubscribed projects, restoring the ability to see a list of all projects just by hitting one key (l) Two nits I'm aware of: * If the user is listing all projects and presses a, the active_only flag will be silently toggled, which may be surprising when they switch back to only subscribed projects and the view is different to when they left that view * If there are circumstances I haven't thought of that could lead to having unreviewed reviews in an unsubscribed project, it might make sense to pay attention to this flag, in which case this patch won't quite do what we want. Change-Id: Id5c27cde7b9536aa9fb0f8ba74276b07019f5d17 --- gertty/db.py | 4 ++-- gertty/view/project_list.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gertty/db.py b/gertty/db.py index 5eb8cb7..956611c 100644 --- a/gertty/db.py +++ b/gertty/db.py @@ -431,8 +431,8 @@ class DatabaseSession(object): query = self.session().query(Project) if subscribed: query = query.filter_by(subscribed=subscribed) - if active_only: - query = query.filter(exists().where(Project.unreviewed_changes)) + if active_only: + query = query.filter(exists().where(Project.unreviewed_changes)) return query.order_by(Project.name).all() def getProject(self, key): diff --git a/gertty/view/project_list.py b/gertty/view/project_list.py index fcf03dc..163288f 100644 --- a/gertty/view/project_list.py +++ b/gertty/view/project_list.py @@ -99,10 +99,10 @@ class ProjectListView(urwid.WidgetWrap): def refresh(self): if self.subscribed: self.title = u'Subscribed Projects' + if self.active_only: + self.title += u' with unreviewed reviews' else: self.title = u'All Projects' - if self.active_only: - self.title += u' with unreviewed reviews' self.app.status.update(title=self.title) unseen_keys = set(self.project_rows.keys()) with self.app.db.getSession() as session: