Using Path() wherever possible in localsettings.py

This commit is contained in:
Philip Sargent 2022-12-22 16:04:16 +00:00
parent f23764c486
commit a72c2bd96a
3 changed files with 5 additions and 24 deletions

View File

@ -29,14 +29,14 @@ from troggle.core.models.survex import SurvexStation
from troggle.core.utils import writetrogglefile
from troggle.core.utils import TROG
# Use the TROG global object to cache the cave lookup list
# Use the TROG global object to cache the cave lookup list. No good for multi-user..
Gcavelookup = TROG['caves']['gcavelookup']
Gcave_count = TROG['caves']['gcavecount']
Gcavelookup = None
Gcave_count = None
'''The model declarations for Areas, Caves and Entrances. Also LogBookENtry, QM, PersonTrip
'''The model declarations for Areas, Caves and Entrances. Also LogBookEntry, QM, PersonTrip
'''
todo='''
@ -166,30 +166,10 @@ class Cave(TroggleModel):
return str(self.slug())
def get_QMs(self):
'''Searches for all QMs that reference this cave. Probably a better Django way to do this
'''Searches for all QMs that reference this cave.
'''
qms = QM.objects.filter(cave=self).order_by('expoyear', 'block__date') # a QuerySet, see https://docs.djangoproject.com/en/4.0/ref/models/querysets/#order-by
return qms # a QuerySet
# undated = []
# dated = []
# qms = QM.objects.filter(cave=self) # a QuerySet
# for q in qms:
# if q.block:
# dated.append(q)
# else:
# undated.append(q)
# sortedqms = sorted(dated, key=operator.attrgetter('block.date')) # sort by date of survexblock the QM was defined in
# orderedqms = sorted(undated, key=operator.attrgetter('expoyear')) # sort by date of expoyear
# return orderedqmcaves + sortedqms # a list, NOT a QuerySet
# def new_QM_number(self, year=datetime.date.today().year):
# """Given a cave and the current year, returns the next QM number."""
# try:
# res=QM.objects.filter(found_by__date__year=year, found_by__cave_slug=self.slug).order_by('-number')[0]
# except IndexError:
# return 1
# return res.number+1CaveAndEntrance
def kat_area(self):
for a in self.area.all():

View File

@ -69,7 +69,7 @@ class MapLocations(object):
def points(self):
for ent in Entrance.objects.all():
if ent.best_station():
print(f"{ent.filename}", end=", ")
# print(f"{ent.filename}", end=", ")
try:
k = ent.caveandentrance_set.all()[0].cave
except:

View File

@ -22,6 +22,7 @@
<h3>Administration Utilities</h3>
<ul>
<li><a href="/pathsreport">Folder paths used</a> -folders settings used by this troggle installation
<li><a href="/aliases/2022">Expoer name aliases</a> -short names recognised by troggle
<li><a href="/dataissues">Data Issues on Imports</a> - warnings and errors from recent data import
<li><a href="/admin/">Django admin</a> - Deep magic access to all models and data
</ul>