2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-05-11 03:04:52 +01:00
This commit is contained in:
2026-05-10 01:36:42 +01:00
parent 16a9e00e48
commit 8c0a2ffaa7
2 changed files with 176 additions and 54 deletions
+51 -22
View File
@@ -2,39 +2,68 @@ from django import forms
class NewHoleForm(forms.Form):
# Identification
tag_id = forms.CharField(label="Cave Tag Identifier", max_length=50)
tag_text = forms.CharField(label="Exact text on tag", widget=forms.Textarea(attrs={'rows': 2}))
tag_id = forms.CharField(label="New Cave Identifier",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 2029-XY-03'}),
max_length=50, required=True)
tag_text = forms.CharField(label="Exact text on tag if placed",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 29 CUCC 35'}),
max_length=50, required=False)
# Naming
proposed_name = forms.CharField(label="Proposed Cave Name",
max_length=90, required=True)
# Discovery
discoverers = forms.CharField(label="Discoverers", max_length=255)
discovery_date = forms.DateField(label="Discovery date", widget=forms.DateInput(attrs={'type': 'date'}))
surface_wallet = forms.CharField(label="Surface survey Wallet", max_length=100)
discoverers = forms.CharField(label="Discoverers / Investigators today",
widget=forms.TextInput(attrs={'placeholder': 'e.g. Dour, Animal, Becka'}),
max_length=255, required=True)
discovery_date = forms.DateField(label="Trip date", widget=forms.DateInput(attrs={'type': 'date'}), required=True)
surface_wallet = forms.CharField(label="Wallet used to find the entrance (if any)",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 2005 # 63'}),
max_length=100, required=False)
# GPS Data
gps_owner = forms.CharField(label="GPS: Whose?", max_length=100)
gps_coords = forms.CharField(label="GPS Coordinates", max_length=100)
gps_dt = forms.DateTimeField(label="Time & date of GPS reading", widget=forms.DateTimeInput(attrs={'type': 'datetime-local'}))
gps_screenshot = forms.BooleanField(label="Screenshot taken of GPS reading?", required=False)
gps_owner = forms.CharField(label="GPS: Whose device?",
widget=forms.TextInput(attrs={'placeholder': 'e.g. Becka'}),
max_length=100, required=True)
gps_lat = forms.FloatField(
label="GPS Latitude",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 47.6964483 N'}), required=True
)
gps_long = forms.FloatField(
label="GPS Longitude",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 13.8160500 E'}), required=True
)
gps_time = forms.TimeField(
label="Time of GPS reading",
widget=forms.TimeInput(attrs={'type': 'time'})
)
gps_screenshot = forms.BooleanField(label="Screenshot taken of GPSTest while GPS device in situ?", required=False)
gps_photo = forms.BooleanField(label="Photo taken of GPS device in situ with view of entrance?", required=False)
# Navigation
dist_to_ent = forms.FloatField(label="Distance from GPS to entrance (m)")
bear_to_ent = forms.FloatField(label="Compass bearing to entrance (degrees)")
dist_to_ent = forms.FloatField(label="Distance from GPS to entrance (m)",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 11.5'})
)
bear_to_ent = forms.FloatField(label="Compass bearing to entrance (degrees)",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 217'})
)
# Status & Surveys
is_explored = forms.BooleanField(label="Completely explored?", required=False)
ug_survey_done = forms.BooleanField(label="Underground survey conducted?", required=False)
ug_survey_wallet = forms.CharField(label="Underground Wallet Name", required=False)
is_explored = forms.BooleanField(label="Exploration complete?", required=False)
ug_survey_done = forms.BooleanField(label="Survex data recorded?", required=False)
ug_survey_wallet = forms.CharField(label="Wallet id for all this data",
widget=forms.TextInput(attrs={'placeholder': 'e.g. 2029 # 88'}),
required=True)
# Media
PHOTO_CHOICES = [('no', 'No'), ('upload', 'Upload now'), ('on_camera', 'On camera (specify who)')]
photo_ent = forms.ChoiceField(label="Photo of entrance?", choices=PHOTO_CHOICES)
photo_ent_who = forms.CharField(label="Who has entrance photo?", required=False)
photo_tag = forms.ChoiceField(label="Photo of tag?", choices=PHOTO_CHOICES)
photo_tag_who = forms.CharField(label="Who has tag photo?", required=False)
# Media: Entrance Photo (Replaced dropdown with checkboxes)
photo_ent_no = forms.BooleanField(label="Entrance photos ?", required=False)
photo_ent_who = forms.CharField(label="Who has entrance photos ?", required=False)
# Naming
proposed_name = forms.CharField(label="Proposed Cave Name", max_length=255)
# Media: Tag Photo (Replaced dropdown with checkboxes)
photo_tag_no = forms.BooleanField(label="Photos of tag ?", required=False)
photo_tag_who = forms.CharField(label="Who has tag photos ?", required=False)
from django.shortcuts import render, redirect
from django.contrib import messages
+125 -32
View File
@@ -4,50 +4,143 @@
{% block extraheaders %}
<style>
/* Mimicking editcave.html style for Django 5.2 <div> rendering */
form div {
margin-bottom: 15px;
}
div > label {
display: block;
font-weight: bold;
margin-top: 5px;
}
input[type="text"], input[type="number"], input[type="date"], textarea, select {
width: 87%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
.submit-btn {
font-weight: bold;
font-size: 150%;
font-variant-caps: small-caps;
margin-left: 40%;
padding: 10px 20px;
}
/* Direct match from editcave.html */
div > label {
display: block;
font-weight: bold;
margin-top: 5px;
}
/* MATCHING FIELD LENGTHS TO DATA SHEET */
div.field-proposed_name input { width: 400px; }
div.field-tag_id input,
div.field-tag_text input,
div.field-discoverers input,
div.field-surface_wallet input,
div.field-ug_survey_wallet input,
div.field-gps_owner input,
div.field-gps_coords input { width: 300px; }
div.field-gps_time input,
div.field-dist_to_ent input,
div.field-bear_to_ent input { width: 80px; }
/* SIDE BY SIDE LAYOUT */
.side-by-side {
display: flex;
gap: 20px;
align-items: flex-start;
}
/* CHECKBOX STYLING TO MATCH editcave.html VISUALLY */
.checkbox-container {
display: flex;
flex-direction: row; /* Keep box on the left */
align-items: center;
gap: 10px;
margin-top: 10px;
}
/* Override the 'block' display only for labels attached to checkboxes */
.checkbox-container label {
display: inline;
margin-top: 0;
font-weight: bold; /* Match editcave.html bolding */
}
.submit-btn {
font-weight: bold;
font-size: 200%; /* Match editcave.html submit size */
font-variant-caps: small-caps;
margin-left: 40%;
padding: 10px 20px;
cursor: pointer;
}
.input-unit-group {
display: flex;
align-items: center;
gap: 5px;
}
.unit-label {
font-weight: bold;
font-size: 1.1em;
color: #555;
}
div.field-gps_lat input,
div.field-gps_long input {
width: 140px;
}
</style>
{% endblock %}
{% block content %}
<h1>New Cave Creation</h1>
<h1>New Cave Datasheet</h1>
<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; padding: 15px; margin-bottom: 20px;">
<p>Please fill this out to record a new discovery in the field. This data matches the physical <strong>New Cave Data Sheet</strong>.</p>
<p>Consult the <a href="/handbook/survey/caveentryfields.html">cave entry fields</a> documentation if you are unsure about specific requirements.</p>
</div>
<h3>Instructions</h3>
<p>Refer to the handbok <a href="">New Cave Datasheet</a> page for what all these mean and how to fill them in.</p>
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{# Django 5.2 default div-based rendering #}
{{ form }}
<div class="form-container">
{% for field in form %}
{# Logic to catch the first coordinate and start a side-by-side div #}
{% if field.name == "gps_lat" %}
<div class="side-by-side">
<div class="field-{{ field.name }}">
{{ field.label_tag }}
{{ field }}<span class="unit-label"> N</span>
{{ field.errors }}
</div>
{% elif field.name == "gps_long" %}
<div class="field-{{ field.name }}">
{{ field.label_tag }}
{{ field }}<span class="unit-label"> E</span>
{{ field.errors }}
</div>
</div> {# Standard Checkbox rendering #}
{% elif field.field.widget.input_type == "checkbox" %}
<div class="field-{{ field.name }} checkbox-container">
{{ field }}
{{ field.label_tag }}
</div>
{{ field.errors }}
{# Standard Field rendering #}
{% else %}
<div class="field-{{ field.name }}">
{{ field.label_tag }}
{{ field }}
{{ field.errors }}
</div>
{% endif %}
{% endfor %}
</div>
<p>
<input class="submit-btn" type="submit" value="Submit New Hole Data" />
<input class="submit-btn" type="submit" value="Submit" />
</p>
</form>
<h3>Field Procedures</h3>
<p>Ensure that the physical data sheet is placed in the plastic wallet with survey notes and sketches before returning to base.</p>
<h3>What this will do:</h3>
<p>
<ul>
<li>Calculate whether this new cave is in area 1623 or 1626
<li>Create a FIXED POINT record by appending to :loser:/fixedpts/gps/auto.svx
<li>Create a new Cave record with associated new Entrance record
<li>Do a git commit (expoweb) of the new Cave and Entrance description files
<li>Do a git commit (loser) of the new GPS position
<li>Update the database with this new information
<li>Create a new Wallet for this information and this trip
<li>Return you to this form if any important data is missing or invalid
<li>If all is correct, will take you to the (new) Wallet for you to upload the photos
</ul>
</p>
{% endblock %}