forked from expo/troggle
bugfixes
This commit is contained in:
parent
3ef5c1aa0b
commit
e7d9e9402a
@ -84,7 +84,7 @@ class SimpleTest(SimpleTestCase):
|
||||
|
||||
import troggle.core.views.expo
|
||||
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.views.auth import login_required_if_public
|
||||
|
||||
|
@ -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()"})
|
||||
|
||||
if slug:
|
||||
entrance = Entrance.objects.get(entranceslug__slug=slug)
|
||||
# entrance = Entrance.objects.get(entranceslug__slug=slug)
|
||||
caveAndEntrance = CaveAndEntrance.objects.get(entrance=entrance, cave=cave)
|
||||
entlettereditable = False
|
||||
else:
|
||||
@ -441,9 +441,9 @@ def edit_entrance(request, path="", caveslug=None, slug=None):
|
||||
entrance.cached_primary_slug = slugname
|
||||
entrance.filename = slugname + ".html"
|
||||
entrance.save()
|
||||
if slug is None:
|
||||
es = EntranceSlug(entrance=entrance, slug=slugname, primary=True)
|
||||
es.save()
|
||||
# if slug is None:
|
||||
# es = EntranceSlug(entrance=entrance, slug=slugname, primary=True)
|
||||
# es.save()
|
||||
entrance_file = entrance.file_output()
|
||||
cave_file = cave.file_output()
|
||||
write_and_commit([entrance_file, cave_file], f"Online edit of {cave}{entletter}")
|
||||
|
@ -372,24 +372,24 @@ def readentrance(filename):
|
||||
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/")
|
||||
print(message)
|
||||
for slug in slugs:
|
||||
# print("entrance slug:{} filename:{}".format(slug, filename))
|
||||
try:
|
||||
EntranceSlug.objects.update_or_create(entrance=e, slug=slug)
|
||||
except:
|
||||
# need to cope with duplicates
|
||||
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/")
|
||||
# kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug, primary=primary)
|
||||
kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug)
|
||||
for k in kents:
|
||||
message = " ! - DUPLICATE in db. entrance:" + str(k.entrance) + ", slug:" + str(k.slug())
|
||||
DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/")
|
||||
print(message)
|
||||
for k in kents:
|
||||
if k.slug() is not None:
|
||||
print(" ! - OVERWRITING this one: slug:" + str(k.slug()))
|
||||
k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes
|
||||
# for slug in slugs:
|
||||
# # print("entrance slug:{} filename:{}".format(slug, filename))
|
||||
# try:
|
||||
# EntranceSlug.objects.update_or_create(entrance=e, slug=slug)
|
||||
# except:
|
||||
# # need to cope with duplicates
|
||||
# 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/")
|
||||
# # kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug, primary=primary)
|
||||
# kents = EntranceSlug.objects.all().filter(entrance=e, slug=slug)
|
||||
# for k in kents:
|
||||
# message = " ! - DUPLICATE in db. entrance:" + str(k.entrance) + ", slug:" + str(k.slug())
|
||||
# DataIssue.objects.create(parser="entrances", message=message, url=f"/cave/{slug}/edit/")
|
||||
# print(message)
|
||||
# for k in kents:
|
||||
# if k.slug() is not None:
|
||||
# print(" ! - OVERWRITING this one: slug:" + str(k.slug()))
|
||||
# k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes
|
||||
|
||||
|
||||
def readcave(filename):
|
||||
@ -541,7 +541,8 @@ def readcave(filename):
|
||||
if eslug in entrances_xslug:
|
||||
entrance = entrances_xslug[eslug]
|
||||
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
|
||||
CaveAndEntrance.objects.update_or_create(
|
||||
cave=c, entrance_letter=letter, entrance=entrance
|
||||
|
Loading…
Reference in New Issue
Block a user