From d31777dc8d008a1cea0c611071f0c64ed72e9542 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 15 Jan 2025 14:34:29 +0000 Subject: [PATCH] initial signup form, copy of PHP --- core/views/expo.py | 71 ++++++++++++++++++ templates/signup.html | 166 ++++++++++++++++++++++++++++++++++++++++++ urls.py | 2 + 3 files changed, 239 insertions(+) create mode 100644 templates/signup.html diff --git a/core/views/expo.py b/core/views/expo.py index 019df18..a6abfc1 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -69,6 +69,33 @@ def spider(request, _): return render(request, "pagenotfound.html", {"path": path}, status=404) # return redirect("/?#") # so that suffixes applied by spider are no longer part of the url +@ensure_csrf_cookie +def signup(request): + if request.method == "POST": # If the form has been submitted... + pageform = ExpoSignupForm(request.POST) # A form bound to the POST data + if pageform.is_valid(): + print(f"form OK") + who = pageform.cleaned_data["name"] + who = git_string(editor) + print(f"{who=}") + return render( + request, + "signup.html", + {"form": pageform, + "year": "2025", "dates": "30th June - 3rd August", + "name": f"{who}", + } + ) + else: + pageform = ExpoSignupForm(initial={"allergies":"None", "medication":"None", "medic_info":"None", }) + return render( + request, + "signup.html", + {"form": pageform, + "year": "2025", "dates": "30th June - 3rd August", + "name": "", "kinname": ""}, + ) + def map(request): """Serves unadorned the expoweb/map/slippy/map.html file""" fn = Path(settings.EXPOWEB, "map", "slippy", "map.html") @@ -550,3 +577,47 @@ class ExpoPageForm(forms.Form): label = "Editor" ) +class ExpoSignupForm(forms.Form): + name = forms.CharField(label='Full name', max_length=100, widget=forms.TextInput(attrs={'tabindex': 1})) + address = forms.CharField(widget=forms.Textarea(attrs={'rows': 7, 'cols': 20, 'tabindex': 2})) + phone = forms.CharField(max_length=15, widget=forms.TextInput(attrs={'tabindex': 3})) + email = forms.EmailField(widget=forms.TextInput(attrs={'tabindex': 4})) + + kinname = forms.CharField(label='Next of Kin name', max_length=100, widget=forms.TextInput(attrs={'tabindex': 5})) + kinaddress = forms.CharField(widget=forms.Textarea(attrs={'rows': 7, 'cols': 20, 'tabindex': 6})) + kinphone = forms.CharField(max_length=15, widget=forms.TextInput(attrs={'tabindex': 7})) + kinemail = forms.EmailField(widget=forms.TextInput(attrs={'tabindex': 8})) + relation = forms.CharField(label='Relation to you', max_length=100, widget=forms.TextInput(attrs={'tabindex': 9})) + + VEGGIE_CHOICES = [ + ('yes', 'Yes'), + ('mostly', 'Mostly'), + ('no', 'No'), + ] + + STUDENT_CHOICES = [ + ('yes', 'Yes'), + ('no', 'No'), + ] + + veggie = forms.ChoiceField(choices=VEGGIE_CHOICES, widget=forms.RadioSelect(attrs={'tabindex': 10})) + student = forms.ChoiceField(choices=STUDENT_CHOICES, widget=forms.RadioSelect(attrs={'tabindex': 11})) + + transport_ok = forms.ChoiceField(choices=[('yes', 'Yes'), ('no', 'No')], + widget=forms.RadioSelect(attrs={'tabindex': 12}), initial='yes') + transport_info = forms.CharField(widget=forms.Textarea(attrs={'rows': 6, 'cols': 80, 'tabindex': 13}), + required=False) + + bivvy = forms.BooleanField(required=False, widget=forms.CheckboxInput(attrs={'tabindex': 14})) + tent = forms.BooleanField(required=False, widget=forms.CheckboxInput(attrs={'tabindex': 15})) + top_tent_cap = forms.IntegerField(required=False, widget=forms.NumberInput(attrs={'tabindex': 16})) + btent = forms.BooleanField(required=False, widget=forms.CheckboxInput(attrs={'tabindex': 17})) + base_tent_cap = forms.IntegerField(required=False, widget=forms.NumberInput(attrs={'tabindex': 18})) + + allergies = forms.CharField(widget=forms.Textarea(attrs={'rows': 2, 'cols': 80, 'tabindex': 19}), required=False) + medication = forms.CharField(widget=forms.Textarea(attrs={'rows': 2, 'cols': 80, 'tabindex': 20}), required=False) + medic_info = forms.CharField(widget=forms.Textarea(attrs={'rows': 5, 'cols': 80, 'tabindex': 21}), required=False) + + extra_info = forms.CharField(widget=forms.Textarea(attrs={'rows': 15, 'cols': 80, 'tabindex': 22}), required=False) + + aims = forms.CharField(widget=forms.Textarea(attrs={'rows': 15, 'cols': 80, 'tabindex': 23}), required=False) diff --git a/templates/signup.html b/templates/signup.html new file mode 100644 index 0000000..e667a4e --- /dev/null +++ b/templates/signup.html @@ -0,0 +1,166 @@ + +{% extends "base.html" %} + +{% block title %} + +Loser Expo 2025 SIGN-UP Form + +{% endblock %} + +{% block extraheaders %} +{% include 'html_editor_scripts_css.html' %} +{% endblock %} +{% block content %} + +{% block head %} +{% endblock %} +{% load static %} + + + + Loser Expo {{year}} Sign-up Form + +

Expo {{year}} Signup Form {{dates}}

+ +

This is the official signup form for Expo {{year}}

+

This form is not secure and by submitting this form you consent to its contents being used for Expo purposes and being included in the Bier Book on Expo.

+

You also give permission for any information you collect on expo (survey data, photos, trip writeups, etc.) to be used in perpetuity for expo-related purposes.

+

BEFORE you fill out this form, you MUST sign up to the expo mailing list. + If you have not signed up to the mailing list, this form will FAIL and you will need to do it all again. + +


+
+ {% csrf_token %} + +

Section A: Personal information

+ +

General

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Your details:Next of kin:
Full name:{{ form.name }}Name:{{ form.kinname }}
Address:{{ form.address }}Address:{{ form.kinaddress }}
Phone:{{ form.phone }}Phone:{{ form.kinphone }}
Email:{{ form.email }}Email:{{ form.kinemail }}
Relation to you:{{ form.relation }}
+ + + + + + + + + + + + + +

Transport

+

Please look now at the transport arrangements page (will open in a new window). Then select one of the following:

+ +

{{ form.transport_ok }}

+ +

If your arrangements are shown incorrectly, then please state the corrected version in the box below. This will automatically be emailed to the transport co-ordinator.

+

{{ form.transport_info }}

+ +

Tents

+

There will be two high camps in 2025:

+ +

There is space for three people in a Club tent at Base Camp. At the stone bridge, a bivvy bag is not essential but useful if you have one.

+

Will you be taking any of the following (please tick/complete as appropriate):

+

{{ form.bivvy }}

+

{{ form.tent }} A {{ form.top_tent_cap }} person tent for the Top Camp site.

+

{{ form.btent }} A {{ form.base_tent_cap }} person tent for Base Camp.

+

Leave the boxes unchecked if you require Club tent space at a particular site.

+ +

Medical

+

The medical information entered here will appear in the Bier Book. Extra medical information may be communicated to + Martin Green; this will be placed in sealed envelopes inside the large first aid kits for use in case of emergency. Please ensure that you communicate such information in good time.

+

Please list any allergies which you have:

+

{{ form.allergies }}

+

Please list any medication which you may be taking in Austria:

+

{{ form.medication }}

+

Please list any other medical conditions you have that the expedition should be aware of:

+

{{ form.medic_info }}

+ +

Other

+

Any other information, including any skills e.g. first aid, languages, etc. that you have:

+

{{ form.extra_info }}

+ +

Section B - Caving/surface work projects

+

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:

+

{{ form.aims }}

+ +
+ +

All done?

+

Click the Preview button below to review your submission.

+ + + +
+

Please report any problems with this form to the webmaster.

+{% endblock %} + \ No newline at end of file diff --git a/urls.py b/urls.py index aa0a8d4..738e502 100644 --- a/urls.py +++ b/urls.py @@ -34,6 +34,7 @@ from troggle.core.views.expo import ( mediapage, pubspage, spider, + signup, ) from troggle.core.views.logbook_edit import logbookedit from troggle.core.views.logbooks import ( @@ -153,6 +154,7 @@ trogglepatterns = [ path('dwguploadnogit/', dwgupload, {'gitdisable': 'yes'}, name='dwguploadnogit'), # used in testing path('logbookedit/', logbookedit, name='logbookedit'), path('logbookedit/', logbookedit, name='logbookedit'), + path('sign_up', signup, name='signup'), # Renaming an uploaded file path('expofilerename/', expofilerename, name='expofilerename'),
Are you a vegetarian?Are you a student/unwaged?
{{ form.veggie }}{{ form.student }}