summaryrefslogtreecommitdiffstats
path: root/parsers
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-04-25 04:04:53 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2021-04-25 04:04:53 +0100
commita656ada67a5b7ff81634f0adcb553de295d624f4 (patch)
tree6b9dc2cd54673247ee9a3e771adbac0be76cbcca /parsers
parent20c42b14bfd62a18648853fc752873f05ec7fe15 (diff)
downloadtroggle-a656ada67a5b7ff81634f0adcb553de295d624f4.tar.gz
troggle-a656ada67a5b7ff81634f0adcb553de295d624f4.tar.bz2
troggle-a656ada67a5b7ff81634f0adcb553de295d624f4.zip
Fixing cave edit form and cave creation parser
Diffstat (limited to 'parsers')
-rw-r--r--parsers/caves.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/parsers/caves.py b/parsers/caves.py
index a263182..8ccaa9d 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -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 = ""):