2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-01-24 15:01:54 +00:00

added more fields

This commit is contained in:
2025-12-28 01:36:24 +00:00
parent 136f9bf935
commit 441dd557eb
2 changed files with 83 additions and 7 deletions

View File

@@ -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 <mta@gasthof.expo>'",
"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;"
})
)

View File

@@ -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 %}
<h1>New Prospect</h1>
<h1>New Cave Prospect</h1>
<p>Please fill in the details for a new prospect: a hole which might be a cave. Fields are documented in the <a href="/handbook/survey/caveentryfields.html">cave entry fields</a> guide.</p>
@@ -54,13 +54,33 @@ New Prospect
<form method="post" class="prospect-form">
{% csrf_token %}
{% for field in form %}
{% if field.name != 'discoverers' and field.name != 'identified_login' and field.name != 'who_are_you' %}
<div>
<label for="{{ field.id_for_label }}">{{ field.label }}</label>
{{ field }}
{% if field.help_text %}<small>{{ field.help_text }}</small>{% endif %}
{% for error in field.errors %}<span class="error">{{ error }}</span>{% endfor %}
</div>
{% endif %}
{% endfor %}
<div>
<label for="{{ form.discoverers.id_for_label }}">{{ form.discoverers.label }}</label>
{{ form.discoverers }}
{% if form.discoverers.help_text %}<small>{{ form.discoverers.help_text }}</small>{% endif %}
{% for error in form.discoverers.errors %}<span class="error">{{ error }}</span>{% endfor %}
</div>
<div>
<label for="{{ form.identified_login.id_for_label }}">{{ form.identified_login.label }}</label>
{{ form.identified_login }}
{% if form.identified_login.help_text %}<small>{{ form.identified_login.help_text }}</small>{% endif %}
{% for error in form.identified_login.errors %}<span class="error">{{ error }}</span>{% endfor %}
</div>
<div>
<label for="{{ form.who_are_you.id_for_label }}">{{ form.who_are_you.label }}</label>
{{ form.who_are_you }}
{% if form.who_are_you.help_text %}<small>{{ form.who_are_you.help_text }}</small>{% endif %}
{% for error in form.who_are_you.errors %}<span class="error">{{ error }}</span>{% endfor %}
</div>
<br>
<button class="fancybutton" style="padding: 0.5em 25px; margin-left: 155px; font-size: 90%;" type="submit">Submit</button>
</form>