2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-26 01:01:53 +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 django.utils.timezone import get_current_timezone, make_aware
from parsers.people import GetPersonExpeditionNameLookup 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 from troggle.core.models.troggle import DataIssue, Expedition
def test_import_core_views_caves(self): def test_import_core_views_caves(self):
from django.conf import settings from django.conf import settings
@ -74,7 +74,7 @@ class SimpleTest(SimpleTestCase):
from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm, from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm,
EntranceForm, EntranceLetterForm) EntranceForm, EntranceLetterForm)
from troggle.core.models.caves import (Area, Cave, CaveAndEntrance, from troggle.core.models.caves import (Area, Cave, CaveAndEntrance,
CaveSlug, Entrance, Entrance,
EntranceSlug, SurvexStation) EntranceSlug, SurvexStation)
from troggle.core.models.troggle import Expedition from troggle.core.models.troggle import Expedition
from troggle.core.views.auth import login_required_if_public from troggle.core.views.auth import login_required_if_public

View File

@ -74,10 +74,7 @@ class CaveAndEntrance(models.Model):
def __str__(self): def __str__(self):
return str(self.cave) + str(self.entrance_letter) 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): class Cave(TroggleModel):
# too much here perhaps, # too much here perhaps,
@ -164,6 +161,7 @@ class Cave(TroggleModel):
def get_QMs(self): def get_QMs(self):
'''Searches for all QMs that reference this cave. '''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 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 return qms # a QuerySet

View File

@ -21,7 +21,7 @@ from django.template import Context, loader
from django.urls import reverse from django.urls import reverse
import settings 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.survex import SurvexStation
from troggle.core.models.troggle import (DataIssue, Expedition, Person, from troggle.core.models.troggle import (DataIssue, Expedition, Person,
PersonExpedition, TroggleModel) PersonExpedition, TroggleModel)
@ -113,6 +113,11 @@ class PersonTrip(TroggleModel):
def __str__(self): def __str__(self):
return f'{self.personexpedition} ({self.logbook_entry.date})' 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): class QM(TroggleModel):
"""This is based on qm.csv in trunk/expoweb/1623/204 which has the fields: """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" "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, from troggle.core.forms import (CaveAndEntranceFormSet, CaveForm, EntranceForm,
EntranceLetterForm) EntranceLetterForm)
from troggle.core.models.caves import (Area, Cave, CaveAndEntrance, from troggle.core.models.caves import (Area, Cave, CaveAndEntrance,
CaveSlug, Entrance, EntranceSlug, Entrance, EntranceSlug,
GetCaveLookup, SurvexStation) 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.models.troggle import DataIssue, Expedition
from troggle.core.utils import write_and_commit, writetrogglefile from troggle.core.utils import write_and_commit, writetrogglefile
from troggle.core.views import expo 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.logbooks import LogbookEntry, PersonTrip
from troggle.core.models.survex import SurvexBlock from troggle.core.models.survex import SurvexBlock
from troggle.core.models.troggle import Expedition, Person, PersonExpedition from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.wallets import Wallet
from troggle.core.utils import TROG from troggle.core.utils import TROG
from troggle.parsers.imports import import_logbook from troggle.parsers.imports import import_logbook
from troggle.parsers.people import GetPersonExpeditionNameLookup from troggle.parsers.people import GetPersonExpeditionNameLookup
@ -206,13 +207,13 @@ def logbookentry(request, date, slug):
jwallets = allwallets.filter(walletdate=date) jwallets = allwallets.filter(walletdate=date)
for j in jwallets: for j in jwallets:
wallets.add(j) wallets.add(j)
thisexpo = this_expedition = Expedition.objects.get(year=int(date[0:4])) # thisexpo = Expedition.objects.get(year=int(date[0:4]))
if thisexpo: # if thisexpo:
expeditionday = thisexpo.get_expedition_day(date) # #expeditionday = thisexpo.get_expedition_day(date)
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday) # svxothers = SurvexBlock.objects.filter(date=date)
else: # else:
svxothers = None # svxothers = None
svxothers = SurvexBlock.objects.filter(date=date)
this_logbookentry=this_logbookentry[0] this_logbookentry=this_logbookentry[0]
# This is the only page that uses presontrip_next and persontrip_prev # This is the only page that uses presontrip_next and persontrip_prev
# and it is calculated on the fly in the model # 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)) thisexpo = Expedition.objects.get(year=int(year))
if samedate: if samedate:
expeditionday = thisexpo.get_expedition_day(samedate) svxothers = SurvexBlock.objects.filter(date=samedate)
#print(f' - {thisexpo=} {expeditionday=}')
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday)
#print(f' - {thisexpo=} {expeditionday=} {svxothers=}')
trips = LogbookEntry.objects.filter(date=samedate) trips = LogbookEntry.objects.filter(date=samedate)
else: else:
svxothers = None svxothers = None

View File

@ -5,7 +5,8 @@ from pathlib import Path
from django.conf import settings from django.conf import settings
from django.db import transaction 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.core.models.troggle import DataIssue
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS, EXPOWEB, SURVEX_DATA from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS, EXPOWEB, SURVEX_DATA