finish event checkins

This commit is contained in:
Cara Salter 2024-08-28 16:51:15 -04:00
parent 302fe4289a
commit 228ff85e6a
No known key found for this signature in database
GPG key ID: A8A3A601440EADA5
4 changed files with 65 additions and 2 deletions

View file

@ -8,7 +8,7 @@ from io import BytesIO
from PIL import Image
import base64
from acmsite.models import Link, Officer, User, Event
from acmsite.models import EventCheckin, Link, Officer, User, Event
from acmsite import models
from .forms import EventForm, LinkForm, OfficerForm
@ -155,6 +155,28 @@ def update_create_event(id):
return redirect(url_for("admin.events"))
@bp.route("/event/<string:id>/checkins")
@login_required
def event_checkins(id):
if not current_user.is_admin:
flash("Unauthorized")
return redirect(url_for("dashboard.home"))
event = db.session.execute(db.select(Event).where(Event.id == id)).scalar_one_or_none()
if event is None:
flash("Invalid event")
return redirect(url_for("admin.events"))
checkins = db.session.execute(db.select(EventCheckin).where(EventCheckin.event ==
id).join(User)).scalars()
processed_checkins = []
for c in checkins:
user = db.session.execute(db.select(User).where(User.id == c.user)).scalar_one_or_none()
processed_checkins.append({"name": f"{user.first_name} {user.last_name}", "email": user.email})
return render_template("admin/checkins.html", checkins=processed_checkins,e=event)
@bp.route("/links")
@login_required
def links():

View file

@ -0,0 +1,35 @@
{% extends "admin/admin-layout.html" %}
{% import "bootstrap5/form.html" as wtf %}
{% block app_content %}
<h1>Checkins for `{{ e.name }}`</h1>
{% for c in checkins %}
{{ c.__dict__ }}
{% endfor %}
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
{% for c in checkins %}
<tr>
<td>{{ c.name }}</td>
<td>{{ c.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h3>Copy-pastable list for CampusGroups</h3>
{% for c in checkins %}
{{ c.email }},
{% endfor %}
{% endblock %}

View file

@ -40,6 +40,11 @@
<li class="dropdown-item">
<a href="#deleteModal"
data-bs-toggle="modal" data-id="{{ e.id }}">Delete Event</a>
</li>
<li class="dropdown-item">
<a href="{{ url_for('admin.event_checkins',
id=e.id) }}">Event Checkins</a>
</li>
</ul>
</div>
</td>

View file

@ -8,7 +8,8 @@
<p>The following events are available for check-in:</p>
{% for e in events %}
<a href="{{ url_for('dashboard.checkin', event_id=e.id) }}">{{ e.name }}</a>
<h5>{{ e.name }} <a class="btn btn-primary" href="{{ url_for('dashboard.checkin', event_id=e.id)
}}">Check in</a></h5>
{% endfor %}
{% else %}
<p>There are no events available for check-in.</p>