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

Rework onsite admin interface #337

Open
wants to merge 46 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
119fc0d
WIP admin JS rewrite.
Syfaro Nov 7, 2024
bc7d431
More cart features.
Syfaro Nov 7, 2024
83ce806
More features.
Syfaro Nov 7, 2024
38900ee
Almost everything working now.
Syfaro Nov 8, 2024
dd23cc1
Remove now unused admin files.
Syfaro Nov 8, 2024
96cb4a9
Significantly improve search result quality.
Syfaro Nov 8, 2024
d5b6022
Remove all global state.
Syfaro Nov 8, 2024
15d284d
Cleanup and layout improvements.
Syfaro Nov 8, 2024
bb14fcf
Minor cleanup.
Syfaro Nov 8, 2024
00e5f27
Color, alignment cleanup.
Syfaro Nov 8, 2024
5f8d3af
More keyboard shortcuts, other cleanup.
Syfaro Nov 8, 2024
8fca02b
Make navbar terminal selection work.
Syfaro Nov 8, 2024
7f1435d
Tweak similarity queries, tiny layout changes.
Syfaro Nov 9, 2024
13272f0
More improvements, better SHC data.
Syfaro Nov 9, 2024
e6a1f46
More minor fixes.
Syfaro Nov 9, 2024
6dca41d
More improvements.
Syfaro Nov 9, 2024
a334025
More small improvements, strict null checks.
Syfaro Nov 9, 2024
130c14b
Change new attendee shortcut.
Syfaro Nov 9, 2024
9b72325
More strict fixes, build improvements.
Syfaro Nov 9, 2024
67a41d0
More dynamic badge templates with Gotenberg.
Syfaro Nov 10, 2024
3510413
Default to existing behavior.
Syfaro Nov 10, 2024
bfb6731
Actually skip printing the badge.
Syfaro Nov 10, 2024
966aa82
Update requirements for gotenberg-client dep.
Syfaro Nov 10, 2024
50d40e5
Add some user settings, race condition fix.
Syfaro Nov 10, 2024
1b6a938
Small ID cleanup.
Syfaro Nov 10, 2024
e944827
Highlight matching badge numbers, other cleanup.
Syfaro Nov 10, 2024
b3ecdfb
Group badges by template when printing.
Syfaro Nov 10, 2024
14e43da
Better cart fetch usage, improve SHC warnings.
Syfaro Nov 10, 2024
a8041b7
More keyboard controls, lock fixes.
Syfaro Nov 10, 2024
52f132c
Fixes for long badge names.
Syfaro Nov 11, 2024
1bed462
Handle initialization errors.
Syfaro Nov 12, 2024
fc13572
Build assets as part of docker build process.
Syfaro Nov 12, 2024
fd97497
Minor cleanup.
Syfaro Nov 13, 2024
16e59f6
More consistent badge display with number.
Syfaro Nov 14, 2024
4bf7a7a
Add search history.
Syfaro Nov 14, 2024
269d05a
Add option to auto print after payment.
Syfaro Nov 14, 2024
b7edd58
Some layout tweaks.
Syfaro Nov 14, 2024
7c728e7
Sentry integration, don't change master layout.
Syfaro Nov 14, 2024
1a6fb1e
Add hopefully functional test for badge printing.
Syfaro Nov 14, 2024
d69fd97
Maybe fix healthcheck command.
Syfaro Nov 14, 2024
2b6b493
Merge branch 'gotenberg-database' into admin-js
Syfaro Nov 14, 2024
691ea48
Add migration for trigram extension.
Syfaro Nov 14, 2024
e7c36d6
Fix issue from merging print changes.
Syfaro Nov 14, 2024
69cb116
Make search a GET request, fix tests.
Syfaro Nov 14, 2024
5894de2
Merge branch 'production' into admin-js
Syfaro Nov 15, 2024
7eff2a7
Update dockerfile base image.
Syfaro Nov 15, 2024
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
10 changes: 10 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ jobs:
# Maps tcp port 5432 on service container to the host
- 5432:5432

gotenberg:
image: gotenberg/gotenberg:8
options: >-
--health-cmd "curl --fail http://localhost:3000/health"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3000:3000

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ venv3/
.env
htmlcov/
.DS_Store
node_modules/
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
FROM node:lts AS assets

ENV NODE_ENVIRONMENT=production

WORKDIR /app/registration/frontend

COPY ./registration/frontend/package.json ./registration/frontend/package-lock.json /app/registration/frontend/
RUN npm install
COPY ./registration/frontend/ /app/registration/frontend/
RUN node esbuild.mjs

FROM ghcr.io/furthemore/apis:apis-base-cb35d5b

LABEL org.opencontainers.image.source="https://github.com/furthemore/APIS"

ARG SENTRY_RELEASE=local
ENV SENTRY_RELEASE ${SENTRY_RELEASE}
ENV SENTRY_RELEASE=${SENTRY_RELEASE}

EXPOSE 80
EXPOSE 443
Expand All @@ -12,6 +23,7 @@ WORKDIR /app

COPY . /app/
COPY ./fm_eventmanager/settings.py.docker /app/fm_eventmanager/settings.py
COPY --from=assets /app/registration/static/ /app/registration/static/

ENTRYPOINT ["/entrypoint.sh"]

Expand Down
3 changes: 3 additions & 0 deletions fm_eventmanager/settings.py.docker
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,6 @@ ENVIRONMENT_NAME = os.getenv('ENVIRONMENT_NAME', "Production Server")
ENVIRONMENT_COLOR = os.getenv('ENVIRONMENT_COLOR', "#FF0000")
ENVIRONMENT_TEXT_COLOR = os.getenv('ENVIRONMENT_TEXT_COLOR', "#00FF00")
ENVIRONMENT_FLOAT = os.getenv('ENVIRONMENT_FLOAT', False)

PRINT_RENDERER = os.getenv('PRINT_RENDERER', 'wkhtmltopdf')
GOTENBERG_HOST = os.getenv('GOTENBERG_HOST', None)
2 changes: 2 additions & 0 deletions fm_eventmanager/settings.py.travis
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,5 @@ ENVIRONMENT_NAME = "Production Server"
ENVIRONMENT_COLOR = "#FF0000"
ENVIRONMENT_TEXT_COLOR = "#00FF00"
ENVIRONMENT_FLOAT = True

GOTENBERG_HOST = "http://localhost:3000"
61 changes: 58 additions & 3 deletions registration/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
from django.contrib import admin, auth, messages
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.signing import TimestampSigner
from django.db import transaction
from django.db.models import JSONField, Max
from django.db.models import Max
from django.forms import NumberInput, widgets
from django.http import HttpResponseRedirect
from django.shortcuts import render
Expand Down Expand Up @@ -544,7 +545,7 @@ class EventAdmin(admin.ModelAdmin):
"venue",
"charity",
"donations",
("codeOfConduct", "badgeTheme"),
("codeOfConduct", "badgeTheme", "defaultBadgeTemplate"),
)
},
),
Expand Down Expand Up @@ -945,7 +946,17 @@ def get_attendee_age(attendee):


def print_badges(modeladmin, request, queryset):
pdf_path = generate_badge_labels(queryset, request)
if getattr(settings, "PRINT_RENDERER", "wkhtmltopdf") == "gotenberg":
signer = TimestampSigner()
data = signer.sign_object({
"badge_ids": [badge.id for badge in queryset],
})

pdf_path = reverse("registration:pdf") + f"?data={data}"
else:
pdf_name = generate_badge_labels(queryset, request)
pdf_path = reverse("registration:pdf") + f"?file={pdf_name}"


response = HttpResponseRedirect(reverse("registration:print"))
url_params = {"file": pdf_path, "next": request.get_full_path()}
Expand Down Expand Up @@ -1615,3 +1626,47 @@ def headers_highlighted(self, instance):


admin.site.register(PaymentWebhookNotification, PaymentWebhookAdmin)


class BadgeTemplateAdmin(admin.ModelAdmin):
list_display = (
"name",
"paperWidth",
"paperHeight",
"marginTop",
"marginBottom",
"marginLeft",
"marginRight",
"landscape",
"scale"
)

fieldsets = (
(
None,
{
"fields": ("name", "template"),
}
),
(
"Paper Setup",
{
"fields": (
"landscape",
"scale",
("paperWidth", "paperHeight"),
)
}
),
(
"Margins And Padding",
{
"fields": (
("marginTop", "marginBottom"),
("marginLeft", "marginRight"),
),
}
),
)

admin.site.register(BadgeTemplate, BadgeTemplateAdmin)
33 changes: 33 additions & 0 deletions registration/frontend/esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { writeFileSync } from "fs";

import esbuild from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
import { solidPlugin } from "esbuild-plugin-solid";

const IS_PROD = process.env.NODE_ENVIRONMENT === "production";

const result = await esbuild.build({
bundle: true,
drop: IS_PROD ? ["console"] : [],
entryPoints: ["src/entrypoints/admin.tsx"],
metafile: true,
minify: IS_PROD,
outdir: "../static/",
sourcemap: true,
target: ["es2020"],
loader: {
".woff": "file",
".woff2": "file",
".ttf": "file",
},
plugins: [
sassPlugin({
quietDeps: ["bulma"],
}),
solidPlugin(),
],
});

if (result.metafile) {
writeFileSync("./metafile.json", JSON.stringify(result.metafile));
}
Loading