Skip to content

Commit

Permalink
Merge pull request #293 from biocore/csymons_perks_20230928
Browse files Browse the repository at this point in the history
Add Perk Fulfillment Toggle to Admin UI
  • Loading branch information
cassidysymons authored Sep 29, 2023
2 parents 5964b7a + baec179 commit 0380e34
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
30 changes: 30 additions & 0 deletions microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,36 @@ def post_account_delete(body):
return get_rootpath()


def get_perk_fulfillment_state():
if not session.get(ADMIN_MODE_KEY, False):
raise Unauthorized()

do_return, diagnostics, _ = ApiRequest.get(
'/admin/perk_fulfillment_state'
)
if do_return:
return diagnostics

pf_state = diagnostics['pf_state']

return _render_with_defaults('admin_perk_fulfillment_state.jinja2',
pf_state=pf_state)


def update_perk_fulfillment_state(perk_fulfillment_state):
if not session.get(ADMIN_MODE_KEY, False):
raise Unauthorized()

do_return, diagnostics, _ = ApiRequest.put(
'/admin/perk_fulfillment_state?perk_fulfillment_state=%s' % (
perk_fulfillment_state,)
)
if do_return:
return diagnostics

return get_perk_fulfillment_state()


def get_interested_users(email=None):
if not session.get(ADMIN_MODE_KEY, False):
raise Unauthorized()
Expand Down
30 changes: 30 additions & 0 deletions microsetta_interface/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,36 @@ paths:
schema:
type: string

'/admin/perk_fulfillment_state':
get:
operationId: microsetta_interface.implementation.get_perk_fulfillment_state
tags:
- Admin
responses:
'200':
description: Current state of whether perk fulfillment tasks are running
content:
text/html:
schema:
type: string
post:
operationId: microsetta_interface.implementation.update_perk_fulfillment_state
tags:
- Admin
parameters:
- in: query
name: perk_fulfillment_state
description: New state of perk fulfillment tasks
schema:
type: boolean
responses:
'200':
description: Updated state of whether perk fulfillment tasks are running
content:
text/html:
schema:
type: string

'/admin/interested_users':
get:
operationId: microsetta_interface.implementation.get_interested_users
Expand Down
14 changes: 14 additions & 0 deletions microsetta_interface/templates/admin_perk_fulfillment_state.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "sitebase.jinja2" %}
{% set page_title = _("Perk Fulfillment State") %}
{% set show_breadcrumbs = False %}
{% block content %}
<div class="container">
Current state of perk_fulfillment_active setting: {{ pf_state }}

<hr />

<form action="/admin/perk_fulfillment_state?perk_fulfillment_state={{ not pf_state }}" method="post">
<input type="submit" value="Switch perk_fulfillment_active to {{ not pf_state }}" />
</form>
</div>
{% endblock %}
5 changes: 3 additions & 2 deletions microsetta_interface/templates/sitebase.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@

{% if admin_mode %}
<nav class="navbar fixed-top navbar-light bg-warning shadow">
{{ _('Administrator Toolbar') }}
{{ _('Admin Tools') }}
<a class="btn btn-outline-success" href="/admin/system_message">{{ _('System Panel') }}</a>
<a class="btn btn-outline-success" href="/admin/emperor_playground">{{ _('Emperor Playground') }}</a>
<a class="btn btn-outline-success" href="/admin/emperor_playground">{{ _('Emperor') }}</a>
<a class="btn btn-outline-success" href="/admin/perk_fulfillment_state">{{ _('Perk Fulfillment') }}</a>
<a class="btn btn-outline-success" href="/admin/interested_users">{{ _('Interested Users') }}</a>
<a class="btn btn-outline-success" href="/admin/address_verification">{{ _('Address Verification') }}</a>
<a class="btn btn-outline-success" href="/admin/campaigns/list">{{ _('Campaigns') }}</a>
Expand Down

0 comments on commit 0380e34

Please sign in to comment.