From 228ff85e6aa535305ffe778c1cefa337cd8bc9b0 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Wed, 28 Aug 2024 16:51:15 -0400 Subject: [PATCH] finish event checkins --- acmsite/admin/__init__.py | 24 +++++++++++++++++- acmsite/templates/admin/checkins.html | 35 +++++++++++++++++++++++++++ acmsite/templates/admin/events.html | 5 ++++ acmsite/templates/dashboard.html | 3 ++- 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 acmsite/templates/admin/checkins.html diff --git a/acmsite/admin/__init__.py b/acmsite/admin/__init__.py index 77b4eef..a042b43 100644 --- a/acmsite/admin/__init__.py +++ b/acmsite/admin/__init__.py @@ -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//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(): diff --git a/acmsite/templates/admin/checkins.html b/acmsite/templates/admin/checkins.html new file mode 100644 index 0000000..70ea0af --- /dev/null +++ b/acmsite/templates/admin/checkins.html @@ -0,0 +1,35 @@ +{% extends "admin/admin-layout.html" %} +{% import "bootstrap5/form.html" as wtf %} + +{% block app_content %} +

Checkins for `{{ e.name }}`

+ + +{% for c in checkins %} + {{ c.__dict__ }} +{% endfor %} + + + + + + + + + + {% for c in checkins %} + + + + + {% endfor %} + +
NameEmail
{{ c.name }}{{ c.email }}
+ +

Copy-pastable list for CampusGroups

+{% for c in checkins %} +{{ c.email }}, +{% endfor %} + + +{% endblock %} diff --git a/acmsite/templates/admin/events.html b/acmsite/templates/admin/events.html index 3297a68..16154f8 100644 --- a/acmsite/templates/admin/events.html +++ b/acmsite/templates/admin/events.html @@ -40,6 +40,11 @@ + diff --git a/acmsite/templates/dashboard.html b/acmsite/templates/dashboard.html index d48d043..550c955 100644 --- a/acmsite/templates/dashboard.html +++ b/acmsite/templates/dashboard.html @@ -8,7 +8,8 @@

The following events are available for check-in:

{% for e in events %} -{{ e.name }} +
{{ e.name }} Check in
{% endfor %} {% else %}

There are no events available for check-in.