mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
make cave url canonical form
This commit is contained in:
parent
f78c719fd7
commit
99b87f808c
@ -69,7 +69,6 @@ class CaveForm(ModelForm):
|
||||
survex_file = forms.CharField(
|
||||
required=False, label="Survex file eg. caves-1623/000/000.svx", widget=forms.TextInput(attrs={"size": "45"})
|
||||
)
|
||||
#url = forms.CharField(required=True, label="URL eg. 1623/000/000 (no .html)", widget=forms.TextInput(attrs={"size": "45"}))
|
||||
length = forms.CharField(required=False, label="Length (m)")
|
||||
depth = forms.CharField(required=False, label="Depth (m)")
|
||||
extent = forms.CharField(required=False, label="Extent (m)")
|
||||
@ -78,9 +77,9 @@ class CaveForm(ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Cave
|
||||
exclude = ("filename",)
|
||||
exclude = ("filename","url")
|
||||
|
||||
field_order = ['unofficial_number', 'kataster_number', 'official_name', 'underground_description', 'explorers', 'equipment', 'survey', 'kataster_status', 'kataster_code','underground_centre_line', 'notes', 'references', 'description_file', 'survex_file', 'areacode', 'url', 'length', 'depth', 'extent']
|
||||
field_order = ['unofficial_number', 'kataster_number', 'official_name', 'underground_description', 'explorers', 'equipment', 'survey', 'kataster_status', 'kataster_code','underground_centre_line', 'notes', 'references', 'description_file', 'survex_file', 'areacode', 'length', 'depth', 'extent']
|
||||
|
||||
def clean_cave_slug(self):
|
||||
if self.cleaned_data["cave_slug"] == "":
|
||||
|
@ -147,11 +147,11 @@ def create_new_cave(svxpath, svxid=None, msg=None):
|
||||
# double check
|
||||
if a[0:3] == "162":
|
||||
areacode = a[0:4]
|
||||
url = f"{areacode}/{caveid}.html" # Note we are appending the .html as we are believe in backwards compatability. This is to fix Martin's new 2023 app.
|
||||
url = f"{areacode}/{caveid}/{caveid}.html" # Note we are appending the .html as we are believe in backwards compatability. This is to fix Martin's new 2023 app.
|
||||
else:
|
||||
print(f"WARNING: parsers/caves/create_new_cave called with svxpath '{svxpath}'. Surely it should start 'caves-162*'? {msg}")
|
||||
areacode = "1623"
|
||||
url = f"1623/{caveid}.html"
|
||||
url = f"1623/{caveid}/{caveid}.html"
|
||||
|
||||
k = f"{areacode}-{caveid}"
|
||||
|
||||
@ -194,7 +194,7 @@ def do_ARGE_cave(slug, caveid, areacode, svxid):
|
||||
"""
|
||||
|
||||
default_note = "This is (probably) an ARGE cave where we only have the survex file and no other information"
|
||||
url = f"{areacode}/{caveid}.html"
|
||||
url = f"{areacode}/{caveid}/{caveid}.html"
|
||||
|
||||
urltest = Cave.objects.filter(url=url)
|
||||
if urltest:
|
||||
@ -643,7 +643,7 @@ def read_cave(filename, cave=None):
|
||||
except:
|
||||
print(f"! Entrance setting failure {slug}")
|
||||
message = f' ! Entrance setting failure, slug:"{slug}" #entrances:{len(entrances)} letter:"{letter}" cave:"{cave}" filename:"cave_data/{filename}"\n{e}'
|
||||
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}_cave_edit/")
|
||||
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.areacode}/{cave.areacode}-{cave.url}_cave_edit/")
|
||||
print(message)
|
||||
def reload_entrances():
|
||||
"""For individual re-reading of a cave_data file when editing,
|
||||
@ -671,10 +671,25 @@ def read_cave(filename, cave=None):
|
||||
#raise
|
||||
# This fails to do an update! It just crashes.. to be fixed
|
||||
message = f" ! CaveSlug update/create failure : {slug}, skipping file cave_data/{context} with exception\nException: {ex.__class__}"
|
||||
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.url}_edit/")
|
||||
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.url()}_edit/")
|
||||
print(message)
|
||||
primary = False
|
||||
|
||||
def check_directory(areacode, caveid, url, cave):
|
||||
dir = Path(settings.EXPOWEB, areacode, caveid)
|
||||
dir_l = Path(settings.EXPOWEB, areacode, caveid.lower())
|
||||
dir_u = Path(settings.EXPOWEB, areacode, caveid.upper())
|
||||
if dir.is_dir():
|
||||
return
|
||||
if dir_l.is_dir() or dir_u.is_dir():
|
||||
message = f" ! Cave URL capitalisation incorrect '{dir}' is not a directory but different capitalisation is. {url=} "
|
||||
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.slug()}_cave_edit/")
|
||||
print(message)
|
||||
return
|
||||
if cave.filename:
|
||||
# not a pending cave, yet the directory does not exist. This is FINE. Many don't (yet)
|
||||
pass
|
||||
|
||||
def check_slug(areacode, kataster_number, unofficial_number, url):
|
||||
if kataster_number:
|
||||
if slug == f"{areacode}-{kataster_number}":
|
||||
@ -806,7 +821,10 @@ def read_cave(filename, cave=None):
|
||||
cave.extent=extent[0]
|
||||
cave.survex_file=survex_file[0]
|
||||
cave.description_file=description_file[0]
|
||||
cave.url=url[0]
|
||||
# cave.url=url[0]
|
||||
# override url in file. We now have a standard canonical form:
|
||||
cave.url = f"{cave.areacode}/{cave.number()}/{cave.number()}.html"
|
||||
check_directory(cave.areacode, cave.number(), cave.url, cave)
|
||||
|
||||
check_slug(cave.areacode,cave.kataster_number, cave.unofficial_number, cave.url)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user