mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
Fixing cave edit form and cave creation parser
This commit is contained in:
parent
20c42b14bf
commit
a656ada67a
@ -46,8 +46,8 @@ class CaveForm(ModelForm):
|
||||
def clean(self):
|
||||
if self.cleaned_data.get("kataster_number") == "" and self.cleaned_data.get("unofficial_number") == "":
|
||||
self._errors["unofficial_number"] = self.error_class(["Either the kataster or unoffical number is required."])
|
||||
if self.cleaned_data.get("kataster_number") != "" and self.cleaned_data.get("official_name") == "":
|
||||
self._errors["official_name"] = self.error_class(["This field is required when there is a kataster number."])
|
||||
# if self.cleaned_data.get("kataster_number") != "" and self.cleaned_data.get("official_name") == "":
|
||||
# self._errors["official_name"] = self.error_class(["This field is required when there is a kataster number."])
|
||||
if self.cleaned_data.get("area") == []:
|
||||
self._errors["area"] = self.error_class(["This field is required."])
|
||||
if self.cleaned_data.get("url") and self.cleaned_data.get("url").startswith("/"):
|
||||
|
@ -227,6 +227,8 @@ def rendercave(request, cave, slug, cave_id=''):
|
||||
else:
|
||||
editable = False
|
||||
#print(f" ! rendercave:'{cave}' svxstem:{svxstem} caveid:'{cave_id}' svx3d:'{svx3d}'")
|
||||
if not cave_id:
|
||||
cave_id = slug # cave.unofficial_number
|
||||
try:
|
||||
r = render(request,'cave.html', {'cave_editable': editable, 'settings': settings, 'cave': cave, 'cavepage': True,
|
||||
'cave_id': cave_id, 'svxstem': svxstem, 'svx3d':svx3d})
|
||||
@ -335,6 +337,8 @@ def edit_cave(request, slug=None):
|
||||
myslug = "%s-%s" % (myArea, form.cleaned_data["unofficial_number"])
|
||||
else:
|
||||
myslug = slug
|
||||
# Converting a PENDING cave to a real cave by saving this form
|
||||
myslug = myslug.replace('-PENDING-', '-')
|
||||
cave.filename = myslug + ".html"
|
||||
cave.save()
|
||||
form.save_m2m()
|
||||
@ -389,7 +393,12 @@ def edit_entrance(request, caveslug=None, slug=None):
|
||||
if form.is_valid() and (slug is not None or entletter.is_valid()):
|
||||
entrance = form.save(commit = False)
|
||||
if slug is None:
|
||||
slugname = cave.slug() + entletter.cleaned_data["entrance_letter"]
|
||||
if entletter.cleaned_data["entrance_letter"]:
|
||||
slugname = cave.slug() + entletter.cleaned_data["entrance_letter"]
|
||||
else:
|
||||
slugname = cave.slug()
|
||||
# Converting a PENDING cave to a real cave by saving this form
|
||||
slugname = slugname.replace('-PENDING-', '-')
|
||||
entrance.cached_primary_slug = slugname
|
||||
entrance.filename = slugname + ".html"
|
||||
entrance.save()
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from django.conf import settings
|
||||
@ -44,24 +45,28 @@ def readcaves():
|
||||
# Do this first, so that these empty entries are overwritten as they get properly created.
|
||||
|
||||
# For those caves which do not have cave_data/1623-xxx.html XML files even though they exist and have surveys
|
||||
# also needs to be done *before* entrances so that the entrance-cave links work properly.
|
||||
pending = ["2007-05", "2007-06", "2007-12", "2009-01", "2009-02",
|
||||
pending = ["2007-06", "2009-01", "2009-02",
|
||||
"2010-06", "2010-07", "2012-ns-01", "2012-ns-02", "2010-04", "2012-ns-05", "2012-ns-06",
|
||||
"2012-ns-07", "2012-ns-08", "2012-ns-12", "2012-ns-14", "2012-ns-15", "2014-bl888",
|
||||
"2018-pf-01", "2018-pf-02", "haldenloch"]
|
||||
|
||||
for k in pending:
|
||||
url = "1623/" + k
|
||||
try:
|
||||
# default for a PENDING cave, ooverwritten if a real cave exists
|
||||
cave = Cave(
|
||||
unofficial_number = k,
|
||||
# official_name = "",
|
||||
underground_description = "Pending cave write-up - creating as empty object. No XML file available yet.",
|
||||
survex_file = "caves-1623/" + k + "/" + k +".svx",
|
||||
url = url,
|
||||
notes="_Survex file found in loser repo but no description in expoweb <br>\n"+
|
||||
"INSTRUCTIONS: First open 'This survex file' (link above the CaveView panel) to find the date and info. Then <br>\n" +
|
||||
"search in the Expo for that year e.g. <a href='/expedition/2007'>2007</a> to find a relevant logbook entry, then <br>\n" +
|
||||
"click on 'New Entrance' at the bottom of this page as we need to create the entrance *first*.")
|
||||
notes=f"_Survex file found in loser repo but no description in expoweb <br><br><br>\n"+
|
||||
f"INSTRUCTIONS: First open 'This survex file' (link above the CaveView panel) to find the date and info. Then " +
|
||||
f"<br>\n - search in the Expo for that year e.g. <a href='/expedition/{k[0:4]}'>{k[0:4]}</a> to find a relevant logbook entry, then \n - " +
|
||||
f"click on 'Edit this cave' and copy the information you find in the survex file and the logbook"+
|
||||
f"<br>\n - " +
|
||||
f"When you Submit it will create a file file in expoweb/cave_data/ " +
|
||||
f"<br>\n - but you have not finished yet. You MUST go and create the entrance: click on New Entrance. Then this will no longer be 'Pending' once the flag has been removed from the code")
|
||||
if cave:
|
||||
cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key.
|
||||
#print(f' ! - READ CAVES: cave {k} {cave}')
|
||||
@ -73,7 +78,7 @@ def readcaves():
|
||||
|
||||
try: # Now create a cave slug ID
|
||||
cs = CaveSlug.objects.update_or_create(cave = cave,
|
||||
slug = "1623-PENDING-" + k,
|
||||
slug = "1623-" + k,
|
||||
primary = False)
|
||||
except:
|
||||
message = " ! {:11s} {} PENDING cave slug create failure".format(k)
|
||||
@ -289,13 +294,13 @@ def readcave(filename):
|
||||
if slug in caves_xslug:
|
||||
cs = caves_xslug[slug]
|
||||
else:
|
||||
try:
|
||||
try: # we want to overwrite a PENDING cave if we are now importing the 1623-xxx.html file for it
|
||||
cs = CaveSlug.objects.update_or_create(cave = c,
|
||||
slug = slug,
|
||||
primary = primary)
|
||||
caves_xslug[slug] = cs
|
||||
except:
|
||||
message = " ! Cave update/create failure: %s, skipping file %s" % (slug, context)
|
||||
except Exception as ex:
|
||||
message = " ! Cave update/create failure : %s, skipping file %s\nException: %s" % (slug, context, ex.__class__)
|
||||
DataIssue.objects.create(parser='caves', message=message)
|
||||
print(message)
|
||||
|
||||
@ -331,7 +336,7 @@ def readcave(filename):
|
||||
#c.save()
|
||||
else: # more than one item in long list
|
||||
message = f' ! ABORT loading this cave. in "{filename}"'
|
||||
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
||||
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slugs}/edit/')
|
||||
print(message)
|
||||
|
||||
def getXML(text, itemname, minItems = 1, maxItems = None, printwarnings = True, context = ""):
|
||||
|
@ -442,15 +442,17 @@ div#scene {
|
||||
{% block contentheader %}
|
||||
<table id="cavepage">
|
||||
<tr>
|
||||
<th id="kat_no">
|
||||
<th id="kat_no"><!-- why is this not showing unofficial_number??-->
|
||||
{% if cave.kataster_number %}
|
||||
{{ cave.kataster_number|safe }}
|
||||
{% if cave.entrancelist %}
|
||||
- {{ cave.entrancelist|safe }}
|
||||
{% endif %}
|
||||
{% if cave.unofficial_number %}
|
||||
{% if cave.unofficial_number %}
|
||||
<br />({{ cave.unofficial_number|safe }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<br />{{ cave_id|safe }}
|
||||
{% endif %}
|
||||
</th>
|
||||
<th id="name">
|
||||
|
Loading…
Reference in New Issue
Block a user