Skip to content

Commit

Permalink
Merge pull request #14356 from canonical/WD-14888-maintenance-window-…
Browse files Browse the repository at this point in the history
…access-control

allow cred admins to schedule exam within maintenance window
  • Loading branch information
usamabinnadeem-10 authored Sep 30, 2024
2 parents b7cf8b9 + 8a53b7a commit d7a4a28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def cred_schedule(
cred_is_in_maintenance,
cred_maintenance_start,
cred_maintenance_end,
is_cred_admin,
trueability_api,
**_,
):
Expand Down Expand Up @@ -295,7 +296,8 @@ def cred_schedule(
parse(cred_maintenance_end) if cred_maintenance_end else None
)
if (
show_cred_maintenance_alert
not is_cred_admin
and show_cred_maintenance_alert
and cred_maintenance_start
and cred_maintenance_end
and (cred_maintenance_start <= starts_at <= cred_maintenance_end)
Expand Down
5 changes: 5 additions & 0 deletions webapp/shop/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,14 @@ def decorated_function(*args, **kwargs):
)
advantage_mapper = AdvantageMapper(ua_contracts_api)
is_community_member = False
is_cred_admin = False
if user_info(flask.session):
is_community_member = user_info(flask.session).get(
"is_community_member", False
)
is_cred_admin = user_info(flask.session).get(
"is_credentials_admin", False
)

return func(
badgr_issuer=os.getenv(
Expand All @@ -177,6 +181,7 @@ def decorated_function(*args, **kwargs):
is_community_member=is_community_member,
show_cred_maintenance_alert=bool(cred_maintenance),
cred_is_in_maintenance=cred_is_in_maintenance,
is_cred_admin=is_cred_admin,
cred_maintenance_start=cred_maintenance_start,
cred_maintenance_end=cred_maintenance_end,
*args,
Expand Down

0 comments on commit d7a4a28

Please sign in to comment.