mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 10:47:22 +00:00
Signup now saves list for bierbook & commits chnages
This commit is contained in:
@@ -20,13 +20,19 @@ from troggle.core.models.troggle import DataIssue, Person
|
||||
from troggle.core.views.editor_helpers import HTMLarea
|
||||
from troggle.core.utils import (
|
||||
add_commit,
|
||||
write_and_commit,
|
||||
current_expo
|
||||
)
|
||||
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.
|
||||
"""
|
||||
SIGNUPS_FILE = "signups.json"
|
||||
SIGNEDUP = "SIGNEDUP"
|
||||
BIERBOOK = "documents/bierbook"
|
||||
BIERFILE = "names.txt"
|
||||
|
||||
SIGNUP_YEAR = "2025"
|
||||
SIGNUP_DATES = "30th June - 3rd August"
|
||||
|
||||
@@ -145,7 +151,7 @@ def read_signups():
|
||||
signups_clear ={}
|
||||
for su, content in signups_dict.items():
|
||||
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)
|
||||
|
||||
return signups_clear
|
||||
@@ -175,6 +181,9 @@ def save_signups(editor, person_slug, clean):
|
||||
raise
|
||||
return render(request, "errors/generic.html", {"message": message})
|
||||
|
||||
print(f"- Exporting bierbook ")
|
||||
write_bierbook(signups_clear, editor)
|
||||
|
||||
def write_signups(signups, encryptedfile, editor):
|
||||
jsondict = { SIGNEDUP: signups }
|
||||
try:
|
||||
@@ -192,6 +201,27 @@ def write_signups(signups, encryptedfile, editor):
|
||||
raise
|
||||
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):
|
||||
name = forms.CharField(label='Full name', max_length=100, widget=forms.TextInput(attrs={'tabindex': 1, 'placeholder': 'Anathema Device'}))
|
||||
|
||||
@@ -21,6 +21,10 @@ Passwords are only ever stored as hashes using the standard Django functions.
|
||||
|
||||
todo = """
|
||||
- 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"
|
||||
@@ -74,6 +78,11 @@ def get_encryptor():
|
||||
|
||||
def load_users():
|
||||
"""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"
|
||||
DataIssue.objects.filter(parser=PARSER_USERS).delete()
|
||||
|
||||
Reference in New Issue
Block a user