diff --git a/core/forms.py b/core/forms.py index 52e19a9..8ad718e 100644 --- a/core/forms.py +++ b/core/forms.py @@ -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 + ) diff --git a/core/views/prospect.py b/core/views/prospect.py index 42eb48b..58a4aab 100644 --- a/core/views/prospect.py +++ b/core/views/prospect.py @@ -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) diff --git a/templates/new_prospect.html b/templates/new_prospect.html new file mode 100644 index 0000000..115efeb --- /dev/null +++ b/templates/new_prospect.html @@ -0,0 +1,56 @@ +{% extends "cavebase.html" %} + +{% block title %} +New Prospect +{% endblock %} + +{% block extraheaders %} +{% include 'html_editor_scripts_css.html' %} +{% endblock %} + +{% block content %} +
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.
+ +{% if success %} + +{% endif %} + + + +{% endblock %} diff --git a/urls.py b/urls.py index 924f5bb..3884992 100644 --- a/urls.py +++ b/urls.py @@ -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"),