Skip to content

Add prelaunch signups to htk #478

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
43 changes: 42 additions & 1 deletion admintools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
from django.shortcuts import redirect

# HTK Imports
from htk.admintools.decorators import company_employee_required
from htk.admintools.utils import retrieve_migrations
from htk.utils import (
htk_setting,
resolve_method_dynamically,
resolve_model_dynamically,
)
from htk.view_helpers import render_custom as _r
from htk.view_helpers import (
add_page_title,
get_view_context,
render_custom as _r,
)


# isort: off
Expand Down Expand Up @@ -150,3 +155,39 @@ def _build_todos_section(todos_config):

response = _r(request, template, data=data)
return response


@company_employee_required
def prelaunch_signups_view(
request,
template='htk/admintools/prelaunch_signups.html',
data=None,
renderer=_r,
base_template=None,
):
"""View for managing prelaunch signups in the admin interface.

This view displays all prelaunch signups and allows for basic management.

Args:
request: The HTTP request
template: The template to use for rendering (default: 'htk/admintools/prelaunch_signups.html')
data: Additional context data (default: None)
renderer: The template renderer to use (default: _r)
base_template: The base template to extend (default: None)
"""
if data is None:
data = get_view_context(request)
add_page_title(
'Prelaunch Signups', data, 'htk_admintools:prelaunch_signups'
)

from htk.apps.prelaunch.loading import PrelaunchSignup

data['prelaunch_signups'] = PrelaunchSignup.objects.all().order_by(
'-created_at'
)
if base_template:
data['base_template'] = base_template
response = renderer(request, template, data=data)
return response
50 changes: 50 additions & 0 deletions templates/htk/admintools/prelaunch_signups.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{% extends base_template|default:'base.html' %}

{% block content %}
<div class="container">
<h1>Prelaunch Signups</h1>

<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Early Access</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for signup in prelaunch_signups %}
<tr>
<td>{{ signup.id }}</td>
<td>{{ signup.full_name }}</td>
<td>{{ signup.email }}</td>
<td>
{% if signup.early_access %}
<span class="badge bg-success">Yes</span>
{% else %}
<span class="badge bg-secondary">No</span>
{% endif %}
</td>
<td>{{ signup.created_at|date:"Y-m-d H:i" }}</td>
<td>
<a href="{% url 'baws_admintools:api:prelaunch_toggle' signup.id %}"
class="btn btn-sm btn-primary"
onclick="event.preventDefault(); if(confirm('Are you sure you want to toggle early access for this user?')) { fetch(this.href).then(() => window.location.reload()); }">
Toggle Early Access
</a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="6" class="text-center">No prelaunch signups found.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}