2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-29 05:11:52 +00:00

bugfix and ongoing issue

This commit is contained in:
Philip Sargent 2023-11-05 21:59:01 +02:00
parent 2c67351424
commit c0687615a4

View File

@ -12,7 +12,7 @@ from troggle.core.models.caves import GetCaveLookup
from troggle.core.models.logbooks import LogbookEntry, writelogbook, PersonLogEntry from troggle.core.models.logbooks import LogbookEntry, writelogbook, PersonLogEntry
from troggle.core.models.survex import DrawingFile from troggle.core.models.survex import DrawingFile
from troggle.core.models.troggle import DataIssue, Expedition, PersonExpedition from troggle.core.models.troggle import DataIssue, Expedition, PersonExpedition
from troggle.core.utils import alphabet_suffix, current_expo, sanitize_name from troggle.core.utils import alphabet_suffix, current_expo, sanitize_name, unique_slug
from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time* # from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
@ -49,9 +49,9 @@ todo = """
def create_new_lbe_slug(date): def create_new_lbe_slug(date):
onthisdate = LogbookEntry.objects.filter(date=date) onthisdate = LogbookEntry.objects.filter(date=date)
n = len(onthisdate) n = len(onthisdate)
# print(f" Already entries on this date: {n}\n {onthisdate}") print(f" Already entries on this date: {n}\n {onthisdate}")
suffix = alphabet_suffix(n) suffix = alphabet_suffix(n+1)
tid = f"{date}{suffix}" tid = f"{date}{suffix}"
print(tid) print(tid)
@ -73,7 +73,7 @@ def store_edited_entry_into_database(date, place, title, text, others, author, t
if LogbookEntry.objects.filter(slug=slug).exists(): if LogbookEntry.objects.filter(slug=slug).exists():
# oops. # oops.
message = " ! - DUPLICATE SLUG for logbook entry " + tripdate + " - " + slug message = f" ! - DUPLICATE SLUG for logbook entry {date} - {slug}"
DataIssue.objects.create(parser="logbooks", message=message) DataIssue.objects.create(parser="logbooks", message=message)
slug = slug + "_" + unique_slug(text,2) slug = slug + "_" + unique_slug(text,2)
@ -157,6 +157,10 @@ def logbookedit(request, year=None, slug=None):
putting the text of the form prompt in red (same as for an invalid date, which is arguably more important). putting the text of the form prompt in red (same as for an invalid date, which is arguably more important).
No check is done on the other people on the trip as this is picked up anyway by parsing on import No check is done on the other people on the trip as this is picked up anyway by parsing on import
and we don't really care at this point. and we don't really care at this point.
If the author name is mispelled, noticed, and chnaged, then two logbook entries are created
with sequential slugs ...b ...c etc. This is because we are doing validation on GET not on POST
and we are not rewriting the URL when a slug gets set. Hmm.
""" """
def validate_year(year): def validate_year(year):
try: try:
@ -202,7 +206,7 @@ def logbookedit(request, year=None, slug=None):
print(message) print(message)
return render(request, "errors/generic.html", {"message": message}) return render(request, "errors/generic.html", {"message": message})
else: else:
# if there is no slug then this is a completely new lbe and we need to enter it into the db # if there is no slug then this is probably a completely new lbe and we need to enter it into the db
# otherwise it is an update # otherwise it is an update
# validation all to be done yet.. # validation all to be done yet..
date = request.POST["date"].strip() date = request.POST["date"].strip()