summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-03-28 20:30:00 +0100
committerPhilip Sargent <philip.sargent@gmail.com>2023-03-28 20:30:00 +0100
commit9ffe3f690b7b691a2ba28c3b0feae728a5aba3e9 (patch)
tree785a68966a3c1ca9e37edd9a445a1faea718172d /core
parente7d9e9402a2a21e0825adc9ad7f4c1327f4c1daf (diff)
downloadtroggle-9ffe3f690b7b691a2ba28c3b0feae728a5aba3e9.tar.gz
troggle-9ffe3f690b7b691a2ba28c3b0feae728a5aba3e9.tar.bz2
troggle-9ffe3f690b7b691a2ba28c3b0feae728a5aba3e9.zip
tidy up entranceSlug all now deleted
Diffstat (limited to 'core')
-rw-r--r--core/forms.py4
-rw-r--r--core/models/caves.py13
-rw-r--r--core/models/logbooks.py2
-rw-r--r--core/views/caves.py27
4 files changed, 9 insertions, 37 deletions
diff --git a/core/forms.py b/core/forms.py
index b0b84c6..8d3ea61 100644
--- a/core/forms.py
+++ b/core/forms.py
@@ -157,13 +157,13 @@ class EntranceForm(ModelForm):
return self.cleaned_data
-# This next line is called from the templates/edit_cave2.html template.
+# This next line is called from the templates/edit_cave.html template.
# This is sufficient to create an entire entry for for the cave fields automatically
# http://localhost:8000/cave/new/
# using django built-in Deep Magic. https://docs.djangoproject.com/en/dev/topics/forms/modelforms/
# for forms which map directly onto a Django Model
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=("cave",))
-
+# This is used only in edit_entrance() in views/caves.py
class EntranceLetterForm(ModelForm):
"""Form to link entrances to caves, along with an entrance number.
diff --git a/core/models/caves.py b/core/models/caves.py
index 8d94086..95cbeec 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -25,11 +25,11 @@ Gcave_count = None
"""
todo = """
-- Find out why we have separate objects CaveSlug and EntranceSlug and why
+- Find out why we have separate objects CaveSlug and why
these are not just a single field on the Model. Do we ever need more
than one slug per cave or entrance? Surely that would break everything??
-- Can we rewrite things to eliminate the CaveSlug and EntranceSlug Classes and objects? Surely
+- Can we rewrite things to eliminate the CaveSlug and objects? Surely
foreign keys work fine ?!
- Why do we have CaveAndEntrance objects ? Surely entranceletter belong son the Entrance object?
@@ -259,15 +259,6 @@ class Cave(TroggleModel):
pass
return lowestareas[0]
-
-# class EntranceSlug(models.Model):
- # """If the Entrance is deleted, then this EntranceSlug is deleted too
- # """
- # entrance = models.ForeignKey("Entrance", on_delete=models.CASCADE)
- # slug = models.SlugField(max_length=50, unique=True)
- # # primary = models.BooleanField(default=False)
-
-
class Entrance(TroggleModel):
MARKING_CHOICES = (
("P", "Paint"),
diff --git a/core/models/logbooks.py b/core/models/logbooks.py
index 361fb96..9a13b59 100644
--- a/core/models/logbooks.py
+++ b/core/models/logbooks.py
@@ -11,7 +11,7 @@ from troggle.core.models.troggle import Expedition, TroggleModel
"""
todo = """
-- Can we rewrite things to eliminate the CaveSlug and EntranceSlug Classes and objects? Surely
+- Can we rewrite things to eliminate the CaveSlug and objects? Surely
foreign keys work fine ?!
"""
diff --git a/core/views/caves.py b/core/views/caves.py
index 475671c..41c14ef 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -10,7 +10,7 @@ from django.urls import NoReverseMatch
import troggle.settings as settings
from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm
-from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup # EntranceSlug,
+from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup
from troggle.core.models.logbooks import CaveSlug, QM
from troggle.core.utils import write_and_commit
from troggle.core.views import expo
@@ -407,8 +407,10 @@ def edit_cave(request, path="", slug=None):
def edit_entrance(request, path="", caveslug=None, slug=None):
"""This is the form that edits the entrance data for a single entrance and writes out
an XML file in the :expoweb: repo folder
+
The format for the file being saved is in templates/dataformat/entrance.xml
- Warning. This uses Django deep magic.
+
+ Warning. This uses Django deep magic for multiple forms and the CaveAndEntrance class.
It does save the data into into the database directly, not by parsing the file.
"""
@@ -419,7 +421,6 @@ 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)
caveAndEntrance = CaveAndEntrance.objects.get(entrance=entrance, cave=cave)
entlettereditable = False
else:
@@ -441,9 +442,6 @@ 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()
entrance_file = entrance.file_output()
cave_file = cave.file_output()
write_and_commit([entrance_file, cave_file], f"Online edit of {cave}{entletter}")
@@ -485,29 +483,12 @@ def ent(request, cave_id, ent_letter):
def cave_debug(request):
ents = Entrance.objects.all().order_by('id')
- #slugs = self.entranceslug_set.filter()
return render(
request,
"cave_debug.html",
{"ents": ents},
)
-# def entranceSlug(request, slug):
-# '''This seems to be a fossil, but I am not sure...
-# '''
-# entrance = Entrance.objects.get(entranceslug__slug = slug)
-# if entrance.non_public and not request.user.is_authenticated:
-# return render(request,'nonpublic.html', {'instance': entrance})
-# else:
-# return render(request,'entranceslug.html', {'entrance': entrance})
-
-# def surveyindex(request):
-# '''The template does not exist, there is no URL which calls this, so it is a fossil
-# '''
-# surveys=Survey.objects.all()
-# expeditions=Expedition.objects.order_by("-year")
-# return render(request,'survey.html',locals())
-
def get_entrances(request, caveslug):
try: