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

add prior expo experience (readonly)

This commit is contained in:
2025-01-26 13:38:10 +00:00
parent 4f1d808720
commit 3ad75d4439
3 changed files with 16 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ from troggle.core.views.editor_helpers import HTMLarea
from troggle.core.utils import ( from troggle.core.utils import (
add_commit, add_commit,
) )
from troggle.parsers.users import get_encryptor, ENCRYPTED_DIR 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.
""" """
@@ -69,7 +69,8 @@ def signup(request):
else: else:
editor = f"troggle <signup_anon@austria.expo>" editor = f"troggle <signup_anon@austria.expo>"
experience = how_many_previous_expos(signup_person)
if request.method == "POST": # If the form has been submitted... if request.method == "POST": # If the form has been submitted...
pageform = ExpoSignupForm(request.POST) # A form bound to the POST data pageform = ExpoSignupForm(request.POST) # A form bound to the POST data
if pageform.is_valid(): if pageform.is_valid():
@@ -103,7 +104,7 @@ def signup(request):
if personal_login: if personal_login:
initial_context["name"] = signup_person.fullname initial_context["name"] = signup_person.fullname
initial_context["email"] = signup_user.email initial_context["email"] = signup_user.email
initial_context["experience"] = experience
pageform = ExpoSignupForm(initial=initial_context) pageform = ExpoSignupForm(initial=initial_context)
@@ -115,7 +116,7 @@ def signup(request):
) )
def read_signups(): def read_signups():
print(f" + READ signups") # print(f" + READ signups")
f = get_encryptor() f = get_encryptor()
signups_dir = settings.EXPOWEB / ENCRYPTED_DIR / current_expo() signups_dir = settings.EXPOWEB / ENCRYPTED_DIR / current_expo()
if not signups_dir.is_dir(): if not signups_dir.is_dir():
@@ -144,7 +145,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 - C signups_dict {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
@@ -238,4 +239,6 @@ class ExpoSignupForm(forms.Form):
'placeholder': 'Estuary english (fluent),\nCan use the potato hut bread machine (level 3 certificate)'}), required=False) 'placeholder': 'Estuary english (fluent),\nCan use the potato hut bread machine (level 3 certificate)'}), required=False)
aims = forms.CharField(widget=forms.Textarea(attrs={'rows': 3, 'cols': 80, 'tabindex': 23, 'placeholder': 'Strolling over the plateau, sunning myself and taking in the views.'}), required=False) aims = forms.CharField(widget=forms.Textarea(attrs={'rows': 3, 'cols': 80, 'tabindex': 23, 'placeholder': 'Strolling over the plateau, sunning myself and taking in the views.'}), required=False)
experience = forms.IntegerField(required=True, widget=forms.TextInput(attrs={'size': 1, 'tabindex': 24, 'readonly': 'readonly'}))

View File

@@ -8,7 +8,8 @@ from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import models from django.db import models
from troggle.core.models.troggle import DataIssue, Person from troggle.core.models.troggle import DataIssue, Person, PersonExpedition
from troggle.core.utils import current_expo
"""This imports the registered troggle users, who are nearly-all, but not quite, Persons. """This imports the registered troggle users, who are nearly-all, but not quite, Persons.
exceptions are "expo" and "expoadmin" which are created by the databaseReset.py import program. exceptions are "expo" and "expoadmin" which are created by the databaseReset.py import program.
@@ -19,12 +20,16 @@ Passwords are only ever stored as hashes using the standard Django functions.
""" """
todo = """ todo = """
- Make all this work with New people who have never been on expo before - Not fully tested, needs experience
""" """
USERS_FILE = "users.json" USERS_FILE = "users.json"
ENCRYPTED_DIR = "encrypted" ENCRYPTED_DIR = "encrypted"
def how_many_previous_expos(person):
return PersonExpedition.objects.filter(person=person).exclude(expedition__year=current_expo()).count()
def register_user(u, email, password=None, pwhash=None, fullname=""): def register_user(u, email, password=None, pwhash=None, fullname=""):
"""Create User and we may not have a Person to tie it to if it is a future caver. """Create User and we may not have a Person to tie it to if it is a future caver.
Do not use the lastname field, put the whole free text identification into firstname Do not use the lastname field, put the whole free text identification into firstname

View File

@@ -135,6 +135,7 @@ Loser Expo {{year}} SIGN-UP Form
<h3>Caving/surface work projects</h3> <h3>Caving/surface work projects</h3>
<p>To assist organisation of gear, it would be helpful to know people's possible aims on Expo. Thus if you have a particular project in mind, please state it below:</p> <p>To assist organisation of gear, it would be helpful to know people's possible aims on Expo. Thus if you have a particular project in mind, please state it below:</p>
<p>{{ form.aims }}</p> <p>{{ form.aims }}</p>
<p>Records show that you have been on {{ form.experience }} previous expos</p>
<h3>Public medical information</h3> <h3>Public medical information</h3>
<p>This is for anything medical you want everyone to be aware of. The medical information entered here will appear, on paper, in the Bier Book. <p>This is for anything medical you want everyone to be aware of. The medical information entered here will appear, on paper, in the Bier Book.