summaryrefslogtreecommitdiffstats
path: root/core/models/troggle.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/models/troggle.py')
-rw-r--r--core/models/troggle.py50
1 files changed, 10 insertions, 40 deletions
diff --git a/core/models/troggle.py b/core/models/troggle.py
index 4651955..6e470b3 100644
--- a/core/models/troggle.py
+++ b/core/models/troggle.py
@@ -51,6 +51,8 @@ class DataIssue(TroggleModel):
We have replaced all assertions in the code with messages and local fix-ups or skips:
https://martinfowler.com/articles/replaceThrowWithNotification.html
+
+ See also the use of stash_data_issue() & store_data_issues() in parsers/survex.py which defer writing to the database until the end of the import.
"""
date = models.DateTimeField(auto_now_add=True, blank=True)
parser = models.CharField(max_length=50, blank=True, null=True)
@@ -81,34 +83,9 @@ class Expedition(TroggleModel):
def get_absolute_url(self):
return urljoin(settings.URL_ROOT, reverse('expedition', args=[self.year]))
- # construction function. should be moved out
- # def get_expedition_day(self, date):
- # expeditiondays = self.expeditionday_set.filter(date=date)
- # if expeditiondays:
- # if len(expeditiondays) == 1:
- # return expeditiondays[0]
- # else:
- # message =f'! - More than one expeditionday for the same date: {date} .\n - This should never happen. \n - Restart mysql and run reset to clean database.'
- # DataIssue.objects.create(parser='expedition', message=message)
- # return expeditiondays[0]
- # res = ExpeditionDay(expedition=self, date=date)
- # res.save()
- # return res
-
- # def day_min(self):
- # """First day of expedition
- # """
- # res = self.expeditionday_set.all()
- # return res and res[0] or None
-
- # def day_max(self):
- # """last day of expedition
- # """
- # res = self.expeditionday_set.all()
- # return res and res[len(res) - 1] or None
class ExpeditionDay(TroggleModel):
- """Exists only on Expedition now. Removed from logbookentry, persontrip, survex stuff etc.
+ """Exists only on Expedition now. Removed links from logbookentry, persontrip, survex stuff etc.
"""
expedition = models.ForeignKey("Expedition",on_delete=models.CASCADE)
date = models.DateField()
@@ -116,11 +93,11 @@ 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
+ # 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
@@ -182,7 +159,7 @@ class PersonExpedition(TroggleModel):
slugfield = models.SlugField(max_length=50,blank=True, null=True) # 2022 to be used in future
is_guest = models.BooleanField(default=False)
- nickname = models.CharField(max_length=100,blank=True, null=True)
+ nickname = models.CharField(max_length=100,blank=True, null=True) # removbe this
class Meta:
ordering = ('-expedition',)
@@ -208,11 +185,4 @@ class PersonExpedition(TroggleModel):
survexblocks = [personrole.survexblock for personrole in self.survexpersonrole_set.all() ]
return sum([survexblock.legslength for survexblock in set(survexblocks)])
- # would prefer to return actual person trips so we could link to first and last ones
- # def day_min(self):
- # res = self.persontrip_set.aggregate(day_min=Min("expeditionday__date"))
- # return res["day_min"]
-
- # def day_max(self):
- # res = self.persontrip_set.all().aggregate(day_max=models.Max("expeditionday__date"))
- # return res["day_max"]
+ \ No newline at end of file