summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-01-30 16:18:19 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2023-01-30 16:18:19 +0000
commitb29ff618718f4d28ae4e5ae338ef0cf7dfb764b9 (patch)
tree3fbbb69224491cc6feca4e31e1f0944b6263fe51
parent58f7cf72d48a89e3bfe32bbde6b47f263121e232 (diff)
downloadtroggle-b29ff618718f4d28ae4e5ae338ef0cf7dfb764b9.tar.gz
troggle-b29ff618718f4d28ae4e5ae338ef0cf7dfb764b9.tar.bz2
troggle-b29ff618718f4d28ae4e5ae338ef0cf7dfb764b9.zip
Renaming class step 2
-rw-r--r--core/TESTS/test_imports.py2
-rw-r--r--core/admin.py8
-rw-r--r--core/models/caves.py2
-rw-r--r--core/models/logbooks.py11
-rw-r--r--core/models/survex.py1
-rw-r--r--core/models/troggle.py5
-rw-r--r--core/views/logbooks.py8
-rw-r--r--core/views/other.py2
-rw-r--r--core/views/survex.py2
-rw-r--r--core/views/uploads.py2
-rw-r--r--parsers/logbooks.py6
-rw-r--r--parsers/survex.py2
12 files changed, 22 insertions, 29 deletions
diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py
index a4a4cfb..e0f420d 100644
--- a/core/TESTS/test_imports.py
+++ b/core/TESTS/test_imports.py
@@ -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
diff --git a/core/admin.py b/core/admin.py
index bc01b52..e9d75e6 100644
--- a/core/admin.py
+++ b/core/admin.py
@@ -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
diff --git a/core/models/caves.py b/core/models/caves.py
index b99140b..921a5a4 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -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='''
diff --git a/core/models/logbooks.py b/core/models/logbooks.py
index 19cd33d..6070003 100644
--- a/core/models/logbooks.py
+++ b/core/models/logbooks.py
@@ -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:
diff --git a/core/models/survex.py b/core/models/survex.py
index 24b679a..e23cd74 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -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):
diff --git a/core/models/troggle.py b/core/models/troggle.py
index 6e470b3..a061ee5 100644
--- a/core/models/troggle.py
+++ b/core/models/troggle.py
@@ -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
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 47aa7e1..4daede9 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -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 = [ ]
diff --git a/core/views/other.py b/core/views/other.py
index 70bdfa4..11a9b8d 100644
--- a/core/views/other.py
+++ b/core/views/other.py
@@ -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
diff --git a/core/views/survex.py b/core/views/survex.py
index 2307298..16a9918 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -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
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 63f6de3..038d0b9 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -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*
diff --git a/parsers/logbooks.py b/parsers/logbooks.py
index f045252..2f077e8 100644
--- a/parsers/logbooks.py
+++ b/parsers/logbooks.py
@@ -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)
diff --git a/parsers/survex.py b/parsers/survex.py
index 4861817..f3bbaf1 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -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):