2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 14:07:07 +00:00

Signup now saves list for bierbook & commits chnages

This commit is contained in:
2025-01-26 14:12:19 +00:00
parent 3ad75d4439
commit 288ce80e07
2 changed files with 40 additions and 1 deletions

View File

@@ -20,13 +20,19 @@ from troggle.core.models.troggle import DataIssue, Person
from troggle.core.views.editor_helpers import HTMLarea from troggle.core.views.editor_helpers import HTMLarea
from troggle.core.utils import ( from troggle.core.utils import (
add_commit, add_commit,
write_and_commit,
current_expo
) )
from troggle.parsers.users import get_encryptor, ENCRYPTED_DIR, how_many_previous_expos from troggle.parsers.users import get_encryptor, ENCRYPTED_DIR, how_many_previous_expos
"""The new user signup form and expo user management system in 2025. """The new user signup form and expo user management system in 2025.
""" """
SIGNUPS_FILE = "signups.json" SIGNUPS_FILE = "signups.json"
SIGNEDUP = "SIGNEDUP" SIGNEDUP = "SIGNEDUP"
BIERBOOK = "documents/bierbook"
BIERFILE = "names.txt"
SIGNUP_YEAR = "2025" SIGNUP_YEAR = "2025"
SIGNUP_DATES = "30th June - 3rd August" SIGNUP_DATES = "30th June - 3rd August"
@@ -145,7 +151,7 @@ def read_signups():
signups_clear ={} signups_clear ={}
for su, content in signups_dict.items(): for su, content in signups_dict.items():
clear_text = f.decrypt(content).decode() clear_text = f.decrypt(content).decode()
print(f"\n - {su} - {clear_text}") # print(f"\n - {su} - {clear_text}")
signups_clear[su] = json.loads(clear_text) signups_clear[su] = json.loads(clear_text)
return signups_clear return signups_clear
@@ -175,6 +181,9 @@ def save_signups(editor, person_slug, clean):
raise raise
return render(request, "errors/generic.html", {"message": message}) return render(request, "errors/generic.html", {"message": message})
print(f"- Exporting bierbook ")
write_bierbook(signups_clear, editor)
def write_signups(signups, encryptedfile, editor): def write_signups(signups, encryptedfile, editor):
jsondict = { SIGNEDUP: signups } jsondict = { SIGNEDUP: signups }
try: try:
@@ -192,6 +201,27 @@ def write_signups(signups, encryptedfile, editor):
raise raise
return True return True
def write_bierbook(signups_clear, editor):
bieryeardir = settings.EXPOWEB / BIERBOOK / current_expo()
bierfile = bieryeardir / BIERFILE
print(bierfile)
names = ""
for id in signups_clear:
names += f"{signups_clear[id]["name"]}\n"
for i in range(0,3):
names += "\\ldots\\ldots\\ldots\n"
print(names)
if not bieryeardir.is_dir():
bieryeardir.mkdir(parents=True, exist_ok=True)
write_and_commit( [(bierfile, names, "utf8")], f"(re)writing bierbook names", editor)
class ExpoSignupForm(forms.Form): class ExpoSignupForm(forms.Form):
name = forms.CharField(label='Full name', max_length=100, widget=forms.TextInput(attrs={'tabindex': 1, 'placeholder': 'Anathema Device'})) name = forms.CharField(label='Full name', max_length=100, widget=forms.TextInput(attrs={'tabindex': 1, 'placeholder': 'Anathema Device'}))

View File

@@ -21,6 +21,10 @@ Passwords are only ever stored as hashes using the standard Django functions.
todo = """ todo = """
- Not fully tested, needs experience - Not fully tested, needs experience
- Need to write to BierBook for signups
- Need to check/register with lists.wookware.org for email
""" """
USERS_FILE = "users.json" USERS_FILE = "users.json"
@@ -74,6 +78,11 @@ def get_encryptor():
def load_users(): def load_users():
"""These are the previously registered users of the troggle system. """These are the previously registered users of the troggle system.
It loads then from JSON permanent storage into the database.
It does allow unencrypted emails in the import, if labelled as such, but only
stores encrypted emails.
It refreshes the JSON every time this functionis called, to allow
for password rotation in the future.
""" """
PARSER_USERS = "_users" PARSER_USERS = "_users"
DataIssue.objects.filter(parser=PARSER_USERS).delete() DataIssue.objects.filter(parser=PARSER_USERS).delete()