2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-03-31 18:06:03 +01: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): def signupok(request):
signup_user = request.user signup_user = request.user
signedup_people = []
signups_clear = read_signups()
for su in signups_clear:
signedup_people.append(su)
return render( return render(
request, "login/signupok.html", 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): def signup(request):
@@ -58,7 +63,7 @@ def signup(request):
# someone like "fluffy-bunny" not associated with a Person # someone like "fluffy-bunny" not associated with a Person
return HttpResponseRedirect("/accounts/login/?next=/signup") return HttpResponseRedirect("/accounts/login/?next=/signup")
signup_person = people[0] 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... 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
@@ -77,17 +82,25 @@ def signup(request):
} }
) )
else: else:
initial_context = {"allergies":"None", signups_clear = read_signups()
"medication":"None", if signup_user.username in signups_clear:
"medic_info":"None", # pre-load form with previously saved data
"veggie": "mostly", initial_context = signups_clear[signup_user.username]
"student": "no", else:
"top_tent_cap": 2, initial_context = {"allergies":"None",
"base_tent_cap": 3, "medication":"None",
} "medic_info":"None",
"veggie": "mostly",
"student": "no",
"top_tent_cap": 2,
"base_tent_cap": 3,
}
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
pageform = ExpoSignupForm(initial=initial_context) pageform = ExpoSignupForm(initial=initial_context)
return render( return render(
request, "login/signup.html", request, "login/signup.html",
@@ -127,7 +140,7 @@ def read_signups():
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 - C signups_dict {su} - {clear_text}")
signups_clear[su] = clear_text signups_clear[su] = json.loads(clear_text)
return signups_clear return signups_clear

View File

@@ -11,9 +11,13 @@
<div id="col1"> <div id="col1">
{% if signup_user %}
<h3>You have signed up to attend the next Expo</h3> <h3>You have signed up to attend the next Expo</h3>
{% else %}
<h3>Signup confirmation: NOBODY</h3>
{% endif %}
<p class="indent"> <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"> <p class="indent">
Your signup has been registered. Please now register your email on the email announcements list if Your signup has been registered. Please now register your email on the email announcements list if
you have not already done so: 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> <li><a href="https://lists.wookware.org/cgi-bin/mailman/listinfo/expo">lists.wookware.org : expo</a>
</ul> </ul>
</p> </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"> <p class="indent">
This is the beginning of becoming part of the team for Expo {{year}}. There are training events and 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 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. particularly need adequate manpower to de-rig the caves and pack up at the end of Expo.
<p class="indent"> <p class="indent">
You next jobs to do: see the <a href="/kanboard/board/2">Expo Kanboard</a>. 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 /> <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 %} {% endblock content %}
{% block margins %} {% block margins %}