From 441dd557eb2e68d97538ed6a6f7c4d634458c725 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 28 Dec 2025 01:36:24 +0000 Subject: [PATCH] added more fields --- core/forms.py | 66 ++++++++++++++++++++++++++++++++++--- templates/new_prospect.html | 24 ++++++++++++-- 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/core/forms.py b/core/forms.py index 83a7a4f..4017aaf 100644 --- a/core/forms.py +++ b/core/forms.py @@ -288,6 +288,31 @@ class EntranceLetterForm(ModelForm): class NewProspectForm(forms.Form): + identified_login = forms.BooleanField( + label="Identified login", + required=False, + widget=forms.CheckboxInput(attrs={"onclick": "return false"}) # makes it readonly + ) + who_are_you = forms.CharField( + label="Who are you", + max_length=100, + required=False, + widget=forms.TextInput(attrs={ + "size": 100, + "placeholder": "You are editing this page, who are you ? e.g. 'Becka' or 'Animal '", + "style": "vertical-align: text-top;" + }) + ) + discoverers = forms.CharField( + label="Names of discoverers", + max_length=100, + required=False, + widget=forms.TextInput(attrs={ + "placeholder": "Becka, Bill, Ted", + "size": 20, + "style": "width: 20ch; min-width: 0;" + }) + ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # If the form is bound (POSTed), update the field's value to uppercase @@ -301,9 +326,18 @@ class NewProspectForm(forms.Form): if 'identifier' in self.initial: self.initial['identifier'] = self.initial['identifier'].upper() def clean_identifier(self): - identifier = self.cleaned_data['identifier'] + identifier = self.cleaned_data.get('identifier') + date_found = self.cleaned_data.get('date_found') if identifier: - return identifier.upper() + identifier = identifier.upper() + # Check year match if date_found is present + if date_found: + year_str = str(date_found.year) + if identifier[:4] != year_str: + raise forms.ValidationError( + f"First 4 characters of identifier ('{identifier[:4]}') must match year {year_str} from date." + ) + return identifier return identifier def clean_date_found(self): date = self.cleaned_data['date_found'] @@ -341,17 +375,39 @@ class NewProspectForm(forms.Form): discovery_name = forms.CharField( label="Discovery Name", max_length=100, - widget=forms.TextInput(attrs={"placeholder": "Dreibierbittehohle"}) + widget=forms.TextInput(attrs={ + "placeholder": "Dreibierbittehohle", + "size": 20, + "style": "width: 20ch; min-width: 0;" + }) ) gps_lat = forms.DecimalField( label="GPS Latitude", max_digits=10, decimal_places=7, - widget=forms.NumberInput(attrs={"placeholder": "47.687180"}) + widget=forms.NumberInput(attrs={ + "placeholder": "47.687180", + "size": 11, + "style": "width: 11ch; min-width: 0;" + }) ) gps_long = forms.DecimalField( label="GPS Longitude", max_digits=10, decimal_places=7, - widget=forms.NumberInput(attrs={"placeholder": "13.825211"}) + widget=forms.NumberInput(attrs={ + "placeholder": "13.825211", + "size": 11, + "style": "width: 11ch; min-width: 0;" + }) + ) + discoverers = forms.CharField( + label="Names of discoverers", + max_length=100, + required=False, + widget=forms.TextInput(attrs={ + "placeholder": "Becka, Bill, Ted", + "size": 20, + "style": "width: 20ch; min-width: 0;" + }) ) diff --git a/templates/new_prospect.html b/templates/new_prospect.html index 0060883..dcd6e7b 100644 --- a/templates/new_prospect.html +++ b/templates/new_prospect.html @@ -1,7 +1,7 @@ {% extends "cavebase.html" %} {% block title %} -New Prospect +New Cave and Entrance {% endblock %} {% block extraheaders %} @@ -9,7 +9,7 @@ New Prospect {% endblock %} {% block content %} -

New Prospect

+

New Cave Prospect

Please fill in the details for a new prospect: a hole which might be a cave. Fields are documented in the cave entry fields guide.

@@ -54,13 +54,33 @@ New Prospect
{% csrf_token %} {% for field in form %} + {% if field.name != 'discoverers' and field.name != 'identified_login' and field.name != 'who_are_you' %}
{{ field }} {% if field.help_text %}{{ field.help_text }}{% endif %} {% for error in field.errors %}{{ error }}{% endfor %}
+ {% endif %} {% endfor %} +
+ + {{ form.discoverers }} + {% if form.discoverers.help_text %}{{ form.discoverers.help_text }}{% endif %} + {% for error in form.discoverers.errors %}{{ error }}{% endfor %} +
+
+ + {{ form.identified_login }} + {% if form.identified_login.help_text %}{{ form.identified_login.help_text }}{% endif %} + {% for error in form.identified_login.errors %}{{ error }}{% endfor %} +
+
+ + {{ form.who_are_you }} + {% if form.who_are_you.help_text %}{{ form.who_are_you.help_text }}{% endif %} + {% for error in form.who_are_you.errors %}{{ error }}{% endfor %} +