2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-01-18 16:42:48 +00:00

initial new prospect form

This commit is contained in:
2025-12-28 00:50:36 +00:00
parent 6fa8f24ba5
commit 8706991888
4 changed files with 102 additions and 4 deletions

View File

@@ -1,4 +1,3 @@
# from tinymce.widgets import TinyMCE
import re
@@ -286,3 +285,32 @@ class EntranceLetterForm(ModelForm):
self.instance.validate_unique()
except forms.ValidationError as e:
self._update_errors(e)
class NewProspectForm(forms.Form):
date_found = forms.DateField(
label="Date Found",
widget=forms.DateInput(attrs={"type": "date"})
)
area_code = forms.CharField(
label="Area Code",
max_length=10
)
identifier = forms.CharField(
label="Identifier (e.g. 2025-AB-01)",
max_length=20
)
discovery_name = forms.CharField(
label="Discovery Name",
max_length=100
)
gps_lat = forms.DecimalField(
label="GPS Latitude",
max_digits=10,
decimal_places=7
)
gps_long = forms.DecimalField(
label="GPS Longitude",
max_digits=10,
decimal_places=7
)

View File

@@ -1,9 +1,10 @@
import os
from django.http import HttpResponse
from django.shortcuts import render
from django.shortcuts import render, redirect
import troggle.settings as settings
from troggle.core.forms import NewProspectForm
from troggle.core.models.caves import Cave, Entrance
from troggle.core.views.caves import caveKey
@@ -301,6 +302,18 @@ def prospecting_image(request, name):
return response
def new_prospect(request):
success = False
if request.method == "POST":
form = NewProspectForm(request.POST)
if form.is_valid():
success = True
# Do not reset the form; keep showing the submitted data
else:
form = NewProspectForm()
return render(request, "new_prospect.html", {"form": form, "success": success})
# def plot(surveypoint, number, point_type, label, mapcode, draw, img):
# try:
# ss = SurvexStation.objects.lookup(surveypoint)

View File

@@ -0,0 +1,56 @@
{% extends "cavebase.html" %}
{% block title %}
New Prospect
{% endblock %}
{% block extraheaders %}
{% include 'html_editor_scripts_css.html' %}
{% endblock %}
{% block content %}
<h1>New 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>
{% if success %}
<div class="success-message">Prospect submitted successfully. You can edit the details below or enter another.</div>
{% endif %}
<style>
div > label {
display:block;
font-weight: bold;
margin-top: 5px;
}
.prospect-form input, .prospect-form select, .prospect-form textarea {
width: 87%;
margin-bottom: 10px;
}
.success-message {
color: green;
font-weight: bold;
margin-bottom: 15px;
}
.form-group {
margin-bottom: 15px;
}
.error {
color: red;
font-size: 90%;
}
</style>
<form method="post" class="prospect-form">
{% csrf_token %}
<div class="form-fields">
{% for field in form %}
<div class="form-group">
<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 %}<div class="error">{{ error }}</div>{% endfor %}
</div>
{% endfor %}
</div>
<p><button class="fancybutton" style="padding: 0.5em 25px; margin-left: 155px; font-size: 90%;" type="submit">Submit</button></p>
</form>
{% endblock %}

View File

@@ -62,7 +62,7 @@ from troggle.core.views.logbooks import (
personexpedition,
)
from troggle.core.views.other import controlpanel, exportlogbook, frontpage, todos, public_laptop, folk_export
from troggle.core.views.prospect import prospecting
from troggle.core.views.prospect import prospecting, new_prospect
from troggle.core.views.user_registration import register, newregister, reset_done, ExpoPasswordResetForm
from troggle.core.views.scans import allscans, cavewallets, scansingle, walletslistperson, walletslistyear
from troggle.core.views.signup import signup, signupok
@@ -92,7 +92,7 @@ The API urls return TSV or JSON and are new in July 2020.
CONVENTION
Unlike most DJango projects, we have the convention that we do NOT have a terminal slash
on the URL of a page which is generated. (Generated pages are neither files not directories.)
on the URL of a page which is generated. (Generated pages are neither files nor directories.)
So the url is "/dwgfiles" not "/dwgfiles/" everywhere, and similarly for "/walletedit" etc.
This is important in troggle because we do NOT universally use the reverse() function
or the url() function to get the URL from the declarations in this url.py file.
@@ -166,6 +166,7 @@ trogglepatterns = [
path('people', notablepersons, name="notablepersons"),
path('people_ids', people_ids, name="people_ids"),
path('folk_export', folk_export, name="folk_export"),
path('newprospect', new_prospect, name="new_prospect"),
path('caveslist', caveslist, name="caveslist"),
path('caves_recent', caves_recent, name="caves_recent"),
path('caves_undropped', caves_undropped, name="caves_undropped"),