2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

fixing cyclic import problem

This commit is contained in:
Philip Sargent 2023-01-29 21:45:51 +00:00
parent 226cbb6b5c
commit 89d0e1723e
7 changed files with 23 additions and 21 deletions

View File

@ -62,7 +62,7 @@ class SimpleTest(SimpleTestCase):
from django.utils.timezone import get_current_timezone, make_aware
from parsers.people import GetPersonExpeditionNameLookup
from troggle.core.models.logbooks import LogbookEntry, PersonTrip
from troggle.core.models.logbooks import CaveSlug, QM, LogbookEntry, PersonTrip
from troggle.core.models.troggle import DataIssue, Expedition
def test_import_core_views_caves(self):
from django.conf import settings
@ -74,7 +74,7 @@ class SimpleTest(SimpleTestCase):
from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm,
EntranceForm, EntranceLetterForm)
from troggle.core.models.caves import (Area, Cave, CaveAndEntrance,
CaveSlug, Entrance,
Entrance,
EntranceSlug, SurvexStation)
from troggle.core.models.troggle import Expedition
from troggle.core.views.auth import login_required_if_public

View File

@ -74,10 +74,7 @@ class CaveAndEntrance(models.Model):
def __str__(self):
return str(self.cave) + str(self.entrance_letter)
class CaveSlug(models.Model):
cave = models.ForeignKey('Cave',on_delete=models.CASCADE)
slug = models.SlugField(max_length=50, unique = True)
primary = models.BooleanField(default=False)
class Cave(TroggleModel):
# too much here perhaps,
@ -164,6 +161,7 @@ class Cave(TroggleModel):
def get_QMs(self):
'''Searches for all QMs that reference this cave.
'''
#qms = self.qm_set.all().order_by('expoyear', 'block__date')
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

View File

@ -21,7 +21,7 @@ from django.template import Context, loader
from django.urls import reverse
import settings
#from troggle.core.models.caves import CaveSlug
#from troggle.core.models.qm import CaveSlug
from troggle.core.models.survex import SurvexStation
from troggle.core.models.troggle import (DataIssue, Expedition, Person,
PersonExpedition, TroggleModel)
@ -113,6 +113,11 @@ class PersonTrip(TroggleModel):
def __str__(self):
return f'{self.personexpedition} ({self.logbook_entry.date})'
class CaveSlug(models.Model):
cave = models.ForeignKey('Cave',on_delete=models.CASCADE)
slug = models.SlugField(max_length=50, unique = True)
primary = models.BooleanField(default=False)
class QM(TroggleModel):
"""This is based on qm.csv in trunk/expoweb/1623/204 which has the fields:
"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"

View File

@ -18,9 +18,9 @@ import troggle.settings as settings
from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm, EntranceForm,
EntranceLetterForm)
from troggle.core.models.caves import (Area, Cave, CaveAndEntrance,
CaveSlug, Entrance, EntranceSlug,
Entrance, EntranceSlug,
GetCaveLookup, SurvexStation)
from troggle.core.models.logbooks import QM
from troggle.core.models.logbooks import CaveSlug, QM
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.utils import write_and_commit, writetrogglefile
from troggle.core.views import expo

View File

@ -17,6 +17,7 @@ import troggle.settings as settings
from troggle.core.models.logbooks import LogbookEntry, PersonTrip
from troggle.core.models.survex import SurvexBlock
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.wallets import Wallet
from troggle.core.utils import TROG
from troggle.parsers.imports import import_logbook
from troggle.parsers.people import GetPersonExpeditionNameLookup
@ -206,13 +207,13 @@ def logbookentry(request, date, slug):
jwallets = allwallets.filter(walletdate=date)
for j in jwallets:
wallets.add(j)
thisexpo = this_expedition = Expedition.objects.get(year=int(date[0:4]))
if thisexpo:
expeditionday = thisexpo.get_expedition_day(date)
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday)
else:
svxothers = None
# thisexpo = Expedition.objects.get(year=int(date[0:4]))
# if thisexpo:
# #expeditionday = thisexpo.get_expedition_day(date)
# svxothers = SurvexBlock.objects.filter(date=date)
# else:
# svxothers = None
svxothers = SurvexBlock.objects.filter(date=date)
this_logbookentry=this_logbookentry[0]
# This is the only page that uses presontrip_next and persontrip_prev
# and it is calculated on the fly in the model

View File

@ -655,10 +655,7 @@ def scanupload(request, path=None):
thisexpo = Expedition.objects.get(year=int(year))
if samedate:
expeditionday = thisexpo.get_expedition_day(samedate)
#print(f' - {thisexpo=} {expeditionday=}')
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday)
#print(f' - {thisexpo=} {expeditionday=} {svxothers=}')
svxothers = SurvexBlock.objects.filter(date=samedate)
trips = LogbookEntry.objects.filter(date=samedate)
else:
svxothers = None

View File

@ -5,7 +5,8 @@ from pathlib import Path
from django.conf import settings
from django.db import transaction
from troggle.core.models.caves import Area, Cave, CaveAndEntrance, CaveSlug, Entrance, EntranceSlug, GetCaveLookup
from troggle.core.models.caves import Area, Cave, CaveAndEntrance, Entrance, EntranceSlug, GetCaveLookup
from troggle.core.models.logbooks import CaveSlug
from troggle.core.models.troggle import DataIssue
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS, EXPOWEB, SURVEX_DATA