diff --git a/core/views/survex.py b/core/views/survex.py index 350c404..df8a629 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -104,10 +104,13 @@ class SvxForm(forms.Form): outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly":True})) code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":36})) + template = False + def GetDiscCode(self): fname = survexdatasetpath / (self.data['filename'] + ".svx") if not os.path.isfile(fname): print(">>> >>> WARNING - svx file not found, showing TEMPLATE SVX",fname, flush=True) + self.template = True return survextemplatefile fin = open(fname, "rt",encoding='utf8',newline='') svxtext = fin.read() @@ -167,6 +170,8 @@ def svx(request, survex_file): editing) with buttons which allow SAVE, check for DIFFerences from saved, and RUN (which runs the cavern executable and displays the output below the main textarea). Requires CSRF to be set upcorrect;ly, and requires permission to write to the filesystem. ''' + warning = False + # get the basic data from the file given in the URL dirname = os.path.split(survex_file)[0] dirname += "/" @@ -210,7 +215,8 @@ def svx(request, survex_file): #process(survex_file) if 'code' not in form.data: form.data['code'] = form.GetDiscCode() - + if form.template: + warning = True if not difflist: difflist.append("none") if message: @@ -220,6 +226,7 @@ def svx(request, survex_file): svxincludes = re.findall(r'\*include\s+(\S+)(?i)', form.data['code'] or "") vmap = {'settings': settings, + 'warning': warning, 'has_3d': os.path.isfile(survexdatasetpath / survex_file / ".3d"), 'title': survex_file, 'svxincludes': svxincludes, diff --git a/parsers/caves.py b/parsers/caves.py index 168e66d..cce680d 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -43,31 +43,34 @@ def readcaves(): print (" - Setting pending caves") # Do this first, so that these empty entries are overwritten as they get properly created. - # For those caves which do not have XML files even though they exist and have surveys + # 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-04", "2007-05", "2007-06", "2007-07", "2007-12", "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", "gruenstein"] + "2018-pf-01", "2018-pf-02", "haldenloch"] for k in pending: - try: + url = "1623/" + k + try: cave = Cave( unofficial_number = k, - # official_name = "", - underground_description = "Pending cave write-up - creating as empty object. No XML file available yet.", - notes="_Survex file found in loser repo but no description in expoweb") + # 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") 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}') cave.area.add(area_1623[0]) cave.save() message = " ! {:11s} {}".format(cave.unofficial_number, cave.underground_description) - DataIssue.objects.create(parser='caves', message=message) + DataIssue.objects.create(parser='caves', message=message, url=url) print(message) try: # Now create a cave slug ID cs = CaveSlug.objects.update_or_create(cave = cave, - slug = "TEMP-" + k, + slug = "1623-PENDING-" + k, primary = False) except: message = " ! {:11s} {} PENDING cave slug create failure".format(k) @@ -316,6 +319,8 @@ def readcave(filename): message = f' ! description filename does not exist :{EXPOWEB}:"{description_file[0]}" in "{filename}"' DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/') print(message) + #c.description_file="" # done only once, to clear out cruft. + #c.save() def getXML(text, itemname, minItems = 1, maxItems = None, printwarnings = True, context = ""): items = re.findall("<%(itemname)s>(.*?)" % {"itemname": itemname}, text, re.S) diff --git a/templates/dataissues.html b/templates/dataissues.html index 46538a0..d42821d 100644 --- a/templates/dataissues.html +++ b/templates/dataissues.html @@ -6,7 +6,7 @@

Loading data from files: Issues arising that need attention

-This is work in progress (April 2021).The URL links to the offending objects are not enabled yet. +This is work in progress (April 2021).The URL links to the offending objects are enabled on only some types of fault as yet.