2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-01-19 20:53:04 +00:00

Pre-load form with saved data

This commit is contained in:
2025-01-25 20:36:35 +00:00
parent 0d105d40da
commit 95ea87233f
2 changed files with 45 additions and 17 deletions

View File

@@ -32,10 +32,15 @@ SIGNUP_DATES = "30th June - 3rd August"
def signupok(request):
signup_user = request.user
signedup_people = []
signups_clear = read_signups()
for su in signups_clear:
signedup_people.append(su)
return render(
request, "login/signupok.html",
{"year": SIGNUP_YEAR, "dates": SIGNUP_DATES, "signup_user": signup_user },
{"year": SIGNUP_YEAR, "dates": SIGNUP_DATES, "signup_user": signup_user, "signedup_people": signedup_people},
)
def signup(request):
@@ -58,7 +63,7 @@ def signup(request):
# someone like "fluffy-bunny" not associated with a Person
return HttpResponseRedirect("/accounts/login/?next=/signup")
signup_person = people[0]
editor = f"{signup_person.fullname} <{signup_user.email}>"
editor = f"{signup_person.fullname} <{signup_user.email}>"
if request.method == "POST": # If the form has been submitted...
pageform = ExpoSignupForm(request.POST) # A form bound to the POST data
@@ -77,17 +82,25 @@ def signup(request):
}
)
else:
initial_context = {"allergies":"None",
"medication":"None",
"medic_info":"None",
"veggie": "mostly",
"student": "no",
"top_tent_cap": 2,
"base_tent_cap": 3,
}
signups_clear = read_signups()
if signup_user.username in signups_clear:
# pre-load form with previously saved data
initial_context = signups_clear[signup_user.username]
else:
initial_context = {"allergies":"None",
"medication":"None",
"medic_info":"None",
"veggie": "mostly",
"student": "no",
"top_tent_cap": 2,
"base_tent_cap": 3,
}
if personal_login:
initial_context["name"] = signup_person.fullname
initial_context["email"] = signup_user.email
pageform = ExpoSignupForm(initial=initial_context)
return render(
request, "login/signup.html",
@@ -127,7 +140,7 @@ def read_signups():
for su, content in signups_dict.items():
clear_text = f.decrypt(content).decode()
print(f"\n - C signups_dict {su} - {clear_text}")
signups_clear[su] = clear_text
signups_clear[su] = json.loads(clear_text)
return signups_clear

View File

@@ -11,9 +11,13 @@
<div id="col1">
{% if signup_user %}
<h3>You have signed up to attend the next Expo</h3>
{% else %}
<h3>Signup confirmation: NOBODY</h3>
{% endif %}
<p class="indent">
You have signed up as {{signup_user.username}} - {{signup_user.email}}
You have signed up as <b>{{signup_user.username}}</b> - <em>{{signup_user.email}}</em>
<p class="indent">
Your signup has been registered. Please now register your email on the email announcements list if
you have not already done so:
@@ -21,18 +25,29 @@ you have not already done so:
<li><a href="https://lists.wookware.org/cgi-bin/mailman/listinfo/expo">lists.wookware.org : expo</a>
</ul>
</p>
<!-- <img src="/expofiles/photos/2007/selected/eishoehle5nial.jpg">-->
<figure align=center class="onright">
<a href="/expofiles/photos/2007/selected/eishoehle4nial.jpg">
<img src="/expofiles/photos/2007/selected/eishoehle4nial.jpg" width="250px"></a>
<figcaption>Nial in <a href="/expofiles/photos/2007/selected/eishoehle4nial.jpg">Eishohle in 2007</a> (Click to enlarge)</figcaption>
</figure>
<p class="indent">
This is the beginning of becoming part of the team for Expo {{year}}. There are training events and
organisation to do, kit-lists to organise, and your dates on expo need to be agreed with Expo. We
particularly need adequate manpower to de-rig the caves and pack up at the end of Expo.
<p class="indent">
You next jobs to do: see the <a href="/kanboard/board/2">Expo Kanboard</a>.
<p class="indent">
Registered cavers so far:<br /><br />
<ul style="list-style: disc">
{% for caver in signedup_people %}
<li><b>{{caver}}</b><br />
{% endfor %}
</ul>
<br />
<!-- <img src="/expofiles/photos/2007/selected/eishoehle5nial.jpg">-->
<figure align=center>
<img src="/expofiles/photos/2007/selected/eishoehle4nial.jpg" width="250px">
<figcaption>Nial in <a href="/expofiles/photos/2007/selected/">Eishohle in 2007</a>.</figcaption>
</figure>
{% endblock content %}
{% block margins %}