forked from expo/troggle
tidy up entranceSlug all now deleted
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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 ?!
|
||||
"""
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user