Skip to content

Commit

Permalink
Split Releases page into active and archived
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Verga <mattia.verga@tiscali.it>
  • Loading branch information
mattiaverga committed Apr 23, 2023
1 parent 7271664 commit 7fc77e2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
6 changes: 6 additions & 0 deletions bodhi-server/bodhi/server/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()."""
Expand Down
25 changes: 17 additions & 8 deletions bodhi-server/bodhi/server/services/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'),
Expand Down
20 changes: 16 additions & 4 deletions bodhi-server/bodhi/server/templates/releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,27 @@
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h3 class="fw-bold m-0">Releases</h3>
% if active:
<h3 class="fw-bold m-0 mb-2">Active Releases</h3>
<span>See here for <a href="${request.route_url('releases')}?active=false">Archived and disabled Releases</a></span>
% else:
<h3 class="fw-bold m-0 mb-2">Archived and disabled Releases</h3>
<span>See here for <a href="${request.route_url('releases')}">Active Releases</a></span>
% endif
</div>
</div>
</div>
</div>
<div class="container pt-2">
${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
</div>

<%block name="javascript">
Expand Down

0 comments on commit 7fc77e2

Please sign in to comment.