diff --git a/core/views/new_hole.py b/core/views/new_hole.py index e208b387..5b94163e 100644 --- a/core/views/new_hole.py +++ b/core/views/new_hole.py @@ -22,6 +22,8 @@ from troggle.core.utils import ( is_identified_user, write_and_commit, ) +from troggle.core.views.caves import get_cave_from_slug + # TO DO check if wallet already exists and if so put a blue label against it & check names are same people # assuming this is a new wallet for now - so add a check for this? @@ -384,11 +386,12 @@ def new_hole(request): editor = git_string(editor) if valid_area: - process_new_hole(form, area) + cave_id = process_new_hole(form, area) - messages.success(request, "New prospect save data successfully saved.") + messages.success(request, "New prospect {cave_id} data successfully saved.") success_url = "/walletedit/" + form.cleaned_data.get('survey_wallet').replace("#",":") + success_url = f"/newholenext/{cave_id}" return redirect(success_url) else: # not in 1623 or 1626 @@ -542,7 +545,7 @@ def process_new_hole(form, area): # SurvexStation objects are x/y/x in UTM and have a function to return lat/long which is a bit silly for many uses # _new_location(fix_id) _newwallet(form, area, editor) - return + return f"{area}-{cave_id}" def _newfix(form, area, editor, cave_id, fix_id_basic): """Constructs and does the edits to the auto GPS file in the loser repo @@ -597,10 +600,12 @@ def _newent(form, areacode, editor, fix_id, cave): marking = "T" # tag else: marking="U" # Unmarked + wallet = form.cleaned_data.get("survey_wallet") ent = Entrance.objects.create( # creates object slug=slug, filename = slug + ".html", findability="S", # Coordinates, Surveyed + findability_description=wallet, marking=marking, approach= form.cleaned_data.get("approach"), entrance_description=form.cleaned_data.get("entrance_description"), @@ -670,4 +675,39 @@ def _savecave(form, areacode, editor, cave): return def _newwallet(form, areacode, editor): - return \ No newline at end of file + return + +from datetime import datetime +from django.db.models import Q +from troggle.core.models.logbooks import LogbookEntry +from troggle.core.models.survex import SurvexFile +from troggle.core.models.wallets import Wallet + +@login_required_if_public +def new_hole_next(request, cave_id): + # extract the information from the Cave and Entrance instead of encoding it in the URL + cave = get_cave_from_slug(cave_id) + name = cave.official_name + area = cave_id[:4] + cave_name = cave_id[5:] + ent = cave.entrances()[0].entrance + datevisit = ent.lastvisit # string + wallet = ent.findability_description + wallet_url = wallet.replace("#", ":") + + try: + odate = datetime.strptime(datevisit.replace(".", "-"), "%Y-%m-%d").date() + date = odate.isoformat() + year = odate.year + except: + year = cave_name[:4] + date = "2025-07-21" + + trips = LogbookEntry.objects.filter(date=date) + wallets = Wallet.objects.filter(Q(survexblock__date=date) | Q(walletdate=date)).distinct() + svxothers = SurvexFile.objects.filter(survexblock__date=date).distinct() + + return render(request, 'new_hole_next.html', + {'cave_id': cave_id, "area": area, "cave_name": cave_name, "name": name, "cave": cave, "ent": ent, + "date": date, "trips": trips, "svxothers": svxothers, "wallet_url": wallet_url, + "wallet": wallet, "wallets": wallets, "year": year}) diff --git a/templates/new_hole_next.html b/templates/new_hole_next.html new file mode 100644 index 00000000..04947a05 --- /dev/null +++ b/templates/new_hole_next.html @@ -0,0 +1,68 @@ +{% extends "cavebase.html" %} + +{% block title %}New Cave & Entrance & Wallet Update Form{% endblock %} + +{% block extraheaders %} +{% endblock %} + +{% block content %} +
If you have not done this before, read New Cave Process. + + + +
Instructions for making a new logbook entry. + +
Edit data for the {{cave_name}} +cave itself. + +
Because ionospheric disturbance happens on a scale of an hour or so, every few hours, +and is local to an area about ~50km in size. If we continuously record the GPS position +of the potato hut during the expo then we will know if the GPS +position of this cave entrancce was recorded during one of these "bad" periods.
+Go back and re-record the GPS position the next day at the exact same point and put that data in the logbook.
+{% endblock %} diff --git a/urls.py b/urls.py index e4a44a1d..67981b52 100644 --- a/urls.py +++ b/urls.py @@ -7,7 +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.new_hole import new_hole, new_hole_next from troggle.core.views.caves import ( cave3d, cave_debug, @@ -260,6 +260,7 @@ trogglepatterns = [ # New hole data input path('newhole', new_hole, name="newhole"), + path('newholenext/