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
This commit is contained in:
James Polley 2014-07-13 17:19:00 +10:00 committed by James E. Blair
parent 85bd6eed69
commit 483ced5f74
2 changed files with 4 additions and 4 deletions

View File

@ -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):

View File

@ -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: