diff --git a/bodhi-server/bodhi/server/schemas.py b/bodhi-server/bodhi/server/schemas.py index bebe903b73..a38aaa1b15 100644 --- a/bodhi-server/bodhi/server/schemas.py +++ b/bodhi-server/bodhi/server/schemas.py @@ -353,6 +353,12 @@ class ListReleaseSchema(PaginatedSchema): missing=None, ) + active = colander.SchemaNode( + colander.Boolean(true_choices=('true', '1')), + location="querystring", + missing=True, + ) + class SaveReleaseSchema(CSRFProtectedSchema, colander.MappingSchema): """An API schema for bodhi.server.services.releases.save_release().""" diff --git a/bodhi-server/bodhi/server/services/releases.py b/bodhi-server/bodhi/server/services/releases.py index f91e2608d2..6c89ea4ee2 100644 --- a/bodhi-server/bodhi/server/services/releases.py +++ b/bodhi-server/bodhi/server/services/releases.py @@ -237,7 +237,7 @@ def _get_status_counts(basequery, status): '{}_updates_total'.format(status.description): basequery.count(), } - def get_update_counts(releaseid): + def get_update_counts(releaseid, stable_only : bool = False): """ Return counts for the various states and types of updates in the given release. @@ -257,19 +257,28 @@ def get_update_counts(releaseid): release = Release.get(releaseid) basequery = Update.query.filter(Update.release == release) counts = {} - counts.update(_get_status_counts(basequery, UpdateStatus.pending)) - counts.update(_get_status_counts(basequery, UpdateStatus.testing)) + if not stable_only: + counts.update(_get_status_counts(basequery, UpdateStatus.pending)) + counts.update(_get_status_counts(basequery, UpdateStatus.testing)) counts.update(_get_status_counts(basequery, UpdateStatus.stable)) return counts + data = request.validated + release_updates_counts = {} releases = Release.all_releases() - for release in (releases['current'] + releases['pending'] + releases['archived'] - + releases['frozen']): - release_updates_counts[release["name"]] = get_update_counts(release["name"]) - - return {"release_updates_counts": release_updates_counts} + active = data.get('active') + if active is False: + for release in (releases['archived'] + releases['disabled']): + release_updates_counts[release["name"]] = get_update_counts(release["name"], + stable_only=True) + else: + for release in (releases['current'] + releases['pending'] + releases['frozen']): + release_updates_counts[release["name"]] = get_update_counts(release["name"]) + + return {"release_updates_counts": release_updates_counts, + "active": active} @releases.get(accept=('application/json', 'text/json'), diff --git a/bodhi-server/bodhi/server/templates/releases.html b/bodhi-server/bodhi/server/templates/releases.html index b619858e30..862ecb01fe 100644 --- a/bodhi-server/bodhi/server/templates/releases.html +++ b/bodhi-server/bodhi/server/templates/releases.html @@ -52,15 +52,27 @@
-

Releases

+ % if active: +

Active Releases

+ See here for Archived and disabled Releases + % else: +

Archived and disabled Releases

+ See here for Active Releases + % endif
- ${release_list('current', stable_only=False)} - ${release_list('pending', stable_only=False)} - ${release_list('archived', stable_only=True)} + % if active: + ${release_list('current', stable_only=False)} + ${release_list('pending', stable_only=False)} + % else: + ${release_list('archived', stable_only=True)} + % if request.releases['disabled']: + ${release_list('disabled', stable_only=True)} + % endif + % endif
<%block name="javascript">