mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
Renaming class step 2
This commit is contained in:
parent
58f7cf72d4
commit
b29ff61871
@ -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 CaveSlug, QM, LogbookEntry, PersonTrip
|
||||
from troggle.core.models.logbooks import CaveSlug, QM, LogbookEntry, PersonLogEntry
|
||||
from troggle.core.models.troggle import DataIssue, Expedition
|
||||
def test_import_core_views_caves(self):
|
||||
from django.conf import settings
|
||||
|
@ -6,7 +6,7 @@ from django.http import HttpResponse
|
||||
|
||||
from troggle.core.models.caves import (Area, Cave, CaveAndEntrance,
|
||||
Entrance)
|
||||
from troggle.core.models.logbooks import (QM, LogbookEntry, PersonTrip)
|
||||
from troggle.core.models.logbooks import (QM, LogbookEntry, PersonLogEntry)
|
||||
from troggle.core.models.survex import (DrawingFile, SingleScan, SurvexBlock,
|
||||
SurvexDirectory, SurvexFile,
|
||||
SurvexPersonRole, SurvexStation)
|
||||
@ -53,8 +53,8 @@ class QMsFoundInline(admin.TabularInline):
|
||||
extra=1
|
||||
|
||||
|
||||
class PersonTripInline(admin.TabularInline):
|
||||
model = PersonTrip
|
||||
class PersonLogEntryInline(admin.TabularInline):
|
||||
model = PersonLogEntry
|
||||
raw_id_fields = ('personexpedition',)
|
||||
extra = 1
|
||||
|
||||
@ -63,7 +63,7 @@ class LogbookEntryAdmin(TroggleModelAdmin):
|
||||
prepopulated_fields = {'slug':("title",)}
|
||||
search_fields = ('title','expedition__year')
|
||||
date_heirarchy = ('date')
|
||||
inlines = (PersonTripInline, QMsFoundInline)
|
||||
inlines = (PersonLogEntryInline, QMsFoundInline)
|
||||
class Media:
|
||||
css = {
|
||||
"all": ("css/troggleadmin.css",) # this does not exist
|
||||
|
@ -34,7 +34,7 @@ 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
|
||||
'''
|
||||
|
||||
todo='''
|
||||
|
@ -25,11 +25,10 @@ from troggle.core.models.survex import SurvexStation
|
||||
from troggle.core.models.troggle import (DataIssue, Expedition, Person,
|
||||
PersonExpedition, TroggleModel)
|
||||
|
||||
'''The model declarations LogBookEntry, PersonTrip, QM
|
||||
'''The model declarations LogBookEntry, PersonLogEntry, QM
|
||||
'''
|
||||
|
||||
todo='''
|
||||
- Rename PersonTrip as PersonLogEntry or similar
|
||||
'''
|
||||
|
||||
class CaveSlug(models.Model):
|
||||
@ -52,7 +51,7 @@ class LogbookEntry(TroggleModel):
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "Logbook Entries"
|
||||
# several PersonTrips point in to this object
|
||||
# several PersonLogEntrys point in to this object
|
||||
ordering = ('-date',)
|
||||
|
||||
def cave(self): # Why didn't he just make this a foreign key to Cave ?
|
||||
@ -91,7 +90,7 @@ class LogbookEntry(TroggleModel):
|
||||
return index
|
||||
|
||||
|
||||
class PersonTrip(TroggleModel):
|
||||
class PersonLogEntry(TroggleModel):
|
||||
"""Single Person going on a trip, which may or may not be written up.
|
||||
It could account for different T/U for people in same logbook entry.
|
||||
"""
|
||||
@ -105,14 +104,14 @@ class PersonTrip(TroggleModel):
|
||||
#order_with_respect_to = 'personexpedition'
|
||||
|
||||
def next_personlog(self):
|
||||
futurePTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
|
||||
futurePTs = PersonLogEntry.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
|
||||
if len(futurePTs) > 0:
|
||||
return futurePTs[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def prev_personlog(self):
|
||||
pastPTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__lt = self.logbook_entry.date).order_by('-logbook_entry__date').all()
|
||||
pastPTs = PersonLogEntry.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__lt = self.logbook_entry.date).order_by('-logbook_entry__date').all()
|
||||
if len(pastPTs) > 0:
|
||||
return pastPTs[0]
|
||||
else:
|
||||
|
@ -162,7 +162,6 @@ class SurvexPersonRole(models.Model):
|
||||
personname = models.CharField(max_length=100)
|
||||
person = models.ForeignKey('Person', blank=True, null=True,on_delete=models.SET_NULL)
|
||||
personexpedition = models.ForeignKey('PersonExpedition', blank=True, null=True,on_delete=models.SET_NULL)
|
||||
# persontrip = models.ForeignKey('PersonTrip', blank=True, null=True,on_delete=models.SET_NULL) # logbook thing not a survex thing
|
||||
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -93,11 +93,6 @@ class ExpeditionDay(TroggleModel):
|
||||
class Meta:
|
||||
ordering = ('date',)
|
||||
|
||||
# def GetPersonTrip(self, personexpedition):
|
||||
# """returns all logbook trips for this expeditonday
|
||||
# """
|
||||
# personexpeditions = self.persontrip_set.filter(expeditionday=self)
|
||||
# return personexpeditions and personexpeditions[0] or None
|
||||
|
||||
class Person(TroggleModel):
|
||||
"""single Person, can go on many years
|
||||
|
@ -14,7 +14,7 @@ from django.utils import timezone
|
||||
from django.views.generic.list import ListView
|
||||
|
||||
import troggle.settings as settings
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonTrip
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry
|
||||
from troggle.core.models.survex import SurvexBlock
|
||||
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
|
||||
from troggle.core.models.wallets import Wallet
|
||||
@ -64,8 +64,8 @@ def expedition(request, expeditionname):
|
||||
|
||||
Remember that 'personexpedition__expedition' is interpreted by Django to mean the
|
||||
'expedition' object which is connected by a foreign key to the 'personexpedition'
|
||||
object, which is a field of the PersonTrip object:
|
||||
PersonTrip.objects.filter(personexpedition__expedition=expo)
|
||||
object, which is a field of the PersonLogEntry object:
|
||||
PersonLogEntry.objects.filter(personexpedition__expedition=expo)
|
||||
|
||||
Queries are not evaluated to hit the database until a result is actually used. Django
|
||||
does lazy evaluation.
|
||||
@ -100,7 +100,7 @@ def expedition(request, expeditionname):
|
||||
dateditems = list(entries) + list(blocks) # evaluates the Django query and hits db
|
||||
dates = sorted(set([item.date for item in dateditems]))
|
||||
|
||||
allpersonlogentries = PersonTrip.objects.filter(personexpedition__expedition=expo)
|
||||
allpersonlogentries = PersonLogEntry.objects.filter(personexpedition__expedition=expo)
|
||||
|
||||
|
||||
personexpeditiondays = [ ]
|
||||
|
@ -13,7 +13,7 @@ from django.template import Context, loader
|
||||
from django.urls import reverse
|
||||
|
||||
from troggle.core.models.caves import Cave
|
||||
from troggle.core.models.logbooks import QM, LogbookEntry, PersonTrip
|
||||
from troggle.core.models.logbooks import QM, LogbookEntry #, PersonLogEntry
|
||||
from troggle.core.models.survex import DrawingFile
|
||||
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
|
||||
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
|
||||
|
@ -15,7 +15,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
import parsers.survex
|
||||
import troggle.settings as settings
|
||||
from troggle.core.models.caves import Cave
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonTrip
|
||||
from troggle.core.models.logbooks import LogbookEntry #, PersonLogEntry
|
||||
from troggle.core.models.survex import (SurvexBlock, SurvexDirectory,
|
||||
SurvexFile, SurvexPersonRole)
|
||||
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
|
||||
|
@ -22,7 +22,7 @@ from django.urls import reverse
|
||||
|
||||
import settings
|
||||
from troggle.core.models.caves import Cave
|
||||
from troggle.core.models.logbooks import QM, LogbookEntry, PersonTrip
|
||||
from troggle.core.models.logbooks import QM, LogbookEntry #, PersonLogEntry
|
||||
from troggle.core.models.survex import (DrawingFile, SurvexBlock, SurvexFile,
|
||||
SurvexPersonRole, Wallet)
|
||||
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
|
||||
|
@ -12,7 +12,7 @@ from django.template.defaultfilters import slugify
|
||||
|
||||
from parsers.people import GetPersonExpeditionNameLookup, load_people_expos
|
||||
from troggle.core.models.caves import GetCaveLookup
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonTrip
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry
|
||||
from troggle.core.models.troggle import DataIssue, Expedition
|
||||
from troggle.core.utils import get_process_memory
|
||||
|
||||
@ -235,7 +235,7 @@ def store_entry_into_database(date, place, tripcave, title, text, trippersons, a
|
||||
for tripperson, time_underground in trippersons:
|
||||
lookupAttribs = {"personexpedition": tripperson, "logbook_entry": lbo}
|
||||
nonLookupAttribs = {"time_underground": time_underground, "is_logbook_entry_author": (tripperson == author)}
|
||||
pt = PersonTrip.objects.create(**nonLookupAttribs, **lookupAttribs)
|
||||
pt = PersonLogEntry.objects.create(**nonLookupAttribs, **lookupAttribs)
|
||||
|
||||
def parser_date(tripdate, year):
|
||||
"""Interprets dates in the expo logbooks and returns a correct datetime.date object"""
|
||||
@ -668,7 +668,7 @@ def LoadLogbooks():
|
||||
# Now we serially store the parsed data in the database, updating 3 types of object:
|
||||
# - Expedition (the 'logbook.html' value)
|
||||
# - LogBookEntry (text, who when etc.)
|
||||
# - PersonTrip (who was on that specific trip mentione din the logbook entry)
|
||||
# - PersonLogEntry (who was on that specific trip mentione din the logbook entry)
|
||||
for entrytuple in allentries:
|
||||
date, place, tripcave, triptitle, text, trippersons, author, expedition, tu, tid = entrytuple
|
||||
store_entry_into_database(date, place, tripcave, triptitle, text, trippersons, author, expedition, tu, tid)
|
||||
|
@ -340,7 +340,7 @@ class LoadingSurvex:
|
||||
*team gb, bl
|
||||
|
||||
personrole is used to record that a person was on a survex trip, NOT the role they played.
|
||||
(NB PersonTrip is a logbook thing, not a survex thing. )
|
||||
(NB PersonLogEntry is a logbook thing, not a survex thing. )
|
||||
"""
|
||||
|
||||
def record_team_member(tm, survexblock):
|
||||
|
Loading…
Reference in New Issue
Block a user