forked from expo/troggle
NewHole form and code
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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}))
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# Navigation
|
||||
dist_to_ent = forms.FloatField(label="Distance from GPS to entrance (m)")
|
||||
bear_to_ent = forms.FloatField(label="Compass bearing to entrance (degrees)")
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# Naming
|
||||
proposed_name = forms.CharField(label="Proposed Cave Name", max_length=255)
|
||||
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib import messages
|
||||
|
||||
def new_hole(request):
|
||||
if request.method == 'POST':
|
||||
form = NewHoleForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
# Data processing to models and filesystem will go here
|
||||
messages.success(request, "New cave data successfully received.")
|
||||
return redirect('some_success_url')
|
||||
else:
|
||||
form = NewHoleForm()
|
||||
|
||||
return render(request, 'new_hole.html', {'form': form})
|
||||
@@ -0,0 +1,53 @@
|
||||
{% extends "cavebase.html" %}
|
||||
|
||||
{% block title %}New Cave Creation Form{% endblock %}
|
||||
|
||||
{% 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;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>New Cave Creation</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>
|
||||
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
|
||||
{# Django 5.2 default div-based rendering #}
|
||||
{{ form }}
|
||||
|
||||
<p>
|
||||
<input class="submit-btn" type="submit" value="Submit New Hole Data" />
|
||||
</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>
|
||||
{% endblock %}
|
||||
@@ -7,6 +7,7 @@ from django.urls import include, path, re_path
|
||||
from troggle.core.views import survex
|
||||
|
||||
from troggle.core.views.auth import expologin, expologout
|
||||
from troggle.core.views.new_hole import new_hole
|
||||
from troggle.core.views.caves import (
|
||||
cave3d,
|
||||
cave_debug,
|
||||
@@ -257,6 +258,8 @@ trogglepatterns = [
|
||||
re_path(r'^getLogBookEntries/(?P<expeditionslug>.*)', get_logbook_entries, name = "get_logbook_entries"),
|
||||
re_path(r'^getEntrances/(?P<caveslug>.*)', get_entrances, name = "get_entrances"),
|
||||
|
||||
# New hole data input
|
||||
path('newhole', new_hole, name="new_hole"),
|
||||
# Cave description pages
|
||||
path('cave/<slug:slug>', caveslugfwd, name="caveslugfwd"),
|
||||
path('cave_debug', cave_debug, name="cave_debug"),
|
||||
|
||||
Reference in New Issue
Block a user