2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-04-03 09:21:48 +01:00
This commit is contained in:
Philip Sargent 2023-03-28 20:05:38 +01:00
parent 3ef5c1aa0b
commit e7d9e9402a
3 changed files with 25 additions and 24 deletions

View File

@ -84,7 +84,7 @@ class SimpleTest(SimpleTestCase):
import troggle.core.views.expo import troggle.core.views.expo
from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm
from troggle.core.models.caves import Area, Cave, CaveAndEntrance, Entrance, EntranceSlug, SurvexStation from troggle.core.models.caves import Area, Cave, CaveAndEntrance, Entrance, SurvexStation #EntranceSlug,
from troggle.core.models.troggle import Expedition from troggle.core.models.troggle import Expedition
from troggle.core.views.auth import login_required_if_public from troggle.core.views.auth import login_required_if_public

View File

@ -419,7 +419,7 @@ def edit_entrance(request, path="", caveslug=None, slug=None):
return render(request, "errors/badslug.html", {"badslug": f"{slug} {caveslug} - from edit_entrance()"}) return render(request, "errors/badslug.html", {"badslug": f"{slug} {caveslug} - from edit_entrance()"})
if slug: if slug:
entrance = Entrance.objects.get(entranceslug__slug=slug) # entrance = Entrance.objects.get(entranceslug__slug=slug)
caveAndEntrance = CaveAndEntrance.objects.get(entrance=entrance, cave=cave) caveAndEntrance = CaveAndEntrance.objects.get(entrance=entrance, cave=cave)
entlettereditable = False entlettereditable = False
else: else:
@ -441,9 +441,9 @@ def edit_entrance(request, path="", caveslug=None, slug=None):
entrance.cached_primary_slug = slugname entrance.cached_primary_slug = slugname
entrance.filename = slugname + ".html" entrance.filename = slugname + ".html"
entrance.save() entrance.save()
if slug is None: # if slug is None:
es = EntranceSlug(entrance=entrance, slug=slugname, primary=True) # es = EntranceSlug(entrance=entrance, slug=slugname, primary=True)
es.save() # es.save()
entrance_file = entrance.file_output() entrance_file = entrance.file_output()
cave_file = cave.file_output() cave_file = cave.file_output()
write_and_commit([entrance_file, cave_file], f"Online edit of {cave}{entletter}") write_and_commit([entrance_file, cave_file], f"Online edit of {cave}{entletter}")

View File

@ -372,24 +372,24 @@ def readentrance(filename):
message = f" ! - More than one slug for an entrance: {entrance}, slugs: {slugs}. Aborting." message = f" ! - More than one slug for an entrance: {entrance}, slugs: {slugs}. Aborting."
DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/") DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/")
print(message) print(message)
for slug in slugs: # for slug in slugs:
# print("entrance slug:{} filename:{}".format(slug, filename)) # # print("entrance slug:{} filename:{}".format(slug, filename))
try: # try:
EntranceSlug.objects.update_or_create(entrance=e, slug=slug) # EntranceSlug.objects.update_or_create(entrance=e, slug=slug)
except: # except:
# need to cope with duplicates # # need to cope with duplicates
message = f" ! FAILED to get precisely one ENTRANCE when updating using: cave_entrance/{filename}" # message = f" ! FAILED to get precisely one ENTRANCE when updating using: cave_entrance/{filename}"
DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/") # DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/")
# kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug, primary=primary) # # kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug, primary=primary)
kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug) # kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug)
for k in kents: # for k in kents:
message = " ! - DUPLICATE in db. entrance:" + str(k.entrance) + ", slug:" + str(k.slug()) # message = " ! - DUPLICATE in db. entrance:" + str(k.entrance) + ", slug:" + str(k.slug())
DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/") # DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/")
print(message) # print(message)
for k in kents: # for k in kents:
if k.slug() is not None: # if k.slug() is not None:
print(" ! - OVERWRITING this one: slug:" + str(k.slug())) # print(" ! - OVERWRITING this one: slug:" + str(k.slug()))
k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes # k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes
def readcave(filename): def readcave(filename):
@ -541,7 +541,8 @@ def readcave(filename):
if eslug in entrances_xslug: if eslug in entrances_xslug:
entrance = entrances_xslug[eslug] entrance = entrances_xslug[eslug]
else: else:
entrance = Entrance.objects.get(entranceslug__slug=eslug) # entrance = Entrance.objects.get(entranceslug__slug=eslug)
entrance = Entrance.objects.get(slug=eslug)
entrances_xslug[eslug] = entrance entrances_xslug[eslug] = entrance
CaveAndEntrance.objects.update_or_create( CaveAndEntrance.objects.update_or_create(
cave=c, entrance_letter=letter, entrance=entrance cave=c, entrance_letter=letter, entrance=entrance