Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Perk Fulfillment Toggle to Admin UI #293

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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