diff --git a/core/fixtures/expo_exped.json b/core/fixtures/expo_exped.json index ebb5053..ac26c05 100644 --- a/core/fixtures/expo_exped.json +++ b/core/fixtures/expo_exped.json @@ -13,6 +13,5 @@ "first_name": "Michael", "last_name": "Sargent", "fullname": "Michael Sargent", "is_vfho": false, "mug_shot": null, - "blurb": "\n\n\n\n\n\n

\n\nMichael Sargent CUCC
\nExpeditions 2014, 15, 16, 17, 18, 19.\n

The first second-generation expo caver in 2014, later members of this exclusive group were Dan Lenartowicz and Sarah Connolly.\n\n\n\n

Pre-expo (pre-student) photos from President's Invite (OUCC) \nand first abseiling instruction (Cambridge).

\n", "orderref": "", - "user": null}} + "blurb": "\n\n\n\n\n\n

\n\nMichael Sargent CUCC
\nExpeditions 2014, 15, 16, 17, 18, 19.\n

The first second-generation expo caver in 2014, later members of this exclusive group were Dan Lenartowicz and Sarah Connolly.\n\n\n\n

Pre-expo (pre-student) photos from President's Invite (OUCC) \nand first abseiling instruction (Cambridge).

\n", "orderref": ""}} ] \ No newline at end of file diff --git a/core/models/logbooks.py b/core/models/logbooks.py index 468b100..b7aa5e3 100644 --- a/core/models/logbooks.py +++ b/core/models/logbooks.py @@ -21,6 +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.survex import SurvexStation from troggle.core.models.troggle import (DataIssue, Expedition, Person, PersonExpedition, TroggleModel) @@ -36,7 +37,7 @@ class LogbookEntry(TroggleModel): """Single parsed entry from Logbook """ date = models.DateField()#MJG wants to turn this into a datetime such that multiple Logbook entries on the same day can be ordered.ld() - expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information) + # expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information) expedition = models.ForeignKey(Expedition,blank=True, null=True,on_delete=models.SET_NULL) # yes this is double- title = models.CharField(max_length=200) cave_slug = models.SlugField(max_length=50, blank=True, null=True) @@ -70,7 +71,14 @@ class LogbookEntry(TroggleModel): LogbookEntry.objects.get(id=self.id-1) def DayIndex(self): - return list(self.expeditionday.logbookentry_set.all()).index(self) + """This is used to set different colours for the different trips on + the calendar view of the expedition""" + index = list(LogbookEntry.objects.filter(date=self.date)).index(self) + if index not in range(0,10): + print(f"Unexpected LogbookEntry DayIndex '{index}' {self}") + index = 0 + return index + class PersonTrip(TroggleModel): """Single Person going on a trip, which may or may not be written up. diff --git a/core/models/survex.py b/core/models/survex.py index e8538f1..4e852f5 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -73,7 +73,6 @@ class SurvexStationLookUpManager(models.Manager): class SurvexStation(models.Model): name = models.CharField(max_length=100) block = models.ForeignKey('SurvexBlock', null=True,on_delete=models.SET_NULL) -# equate = models.ForeignKey('SurvexEquate', blank=True, null=True,on_delete=models.SET_NULL) objects = SurvexStationLookUpManager() x = models.FloatField(blank=True, null=True) y = models.FloatField(blank=True, null=True) @@ -112,7 +111,7 @@ class SurvexBlockLookUpManager(models.Manager): return block class SurvexBlock(models.Model): - """One begin..end block within a survex file. The basic elemt of a survey trip. + """One begin..end block within a survex file. The basic element of a survey trip. """ objects = SurvexBlockLookUpManager() name = models.CharField(max_length=100) @@ -121,7 +120,7 @@ class SurvexBlock(models.Model): cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL) date = models.DateField(blank=True, null=True) - expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL) + #expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL) expedition = models.ForeignKey('Expedition', blank=True, null=True,on_delete=models.SET_NULL) survexfile = models.ForeignKey("SurvexFile", blank=True, null=True,on_delete=models.SET_NULL) @@ -147,7 +146,14 @@ class SurvexBlock(models.Model): return True def DayIndex(self): - return list(self.expeditionday.survexblock_set.all()).index(self) + """This is used to set different colours for the different trips on + the calendar view of the expedition""" + index = list(SurvexBlock.objects.filter(date=self.date)).index(self) + if index not in range(0,10): + print(f"Unexpected SurvexBlock DayIndex '{index}' {self}") + index = 10 + #return list(self.survexblock_set.all()).index(self) + return index class SurvexPersonRole(models.Model): survexblock = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE) diff --git a/core/models/troggle.py b/core/models/troggle.py index 999e826..5ef95c8 100644 --- a/core/models/troggle.py +++ b/core/models/troggle.py @@ -117,7 +117,7 @@ class ExpeditionDay(TroggleModel): ordering = ('date',) def GetPersonTrip(self, personexpedition): - """returns all logbook trips for this expediton + """returns all logbook trips for this expeditonday """ personexpeditions = self.persontrip_set.filter(expeditionday=self) return personexpeditions and personexpeditions[0] or None @@ -132,10 +132,8 @@ class Person(TroggleModel): is_vfho = models.BooleanField(help_text="VFHO is the Vereines für Höhlenkunde in Obersteier, a nearby Austrian caving club.", default=False) mug_shot = models.CharField(max_length=100, blank=True,null=True) blurb = models.TextField(blank=True,null=True) - - #href = models.CharField(max_length=200) orderref = models.CharField(max_length=200) # for alphabetic - user = models.OneToOneField(User, null=True, blank=True,on_delete=models.CASCADE) # not used now + def get_absolute_url(self): return urljoin(settings.URL_ROOT,reverse('person',kwargs={'first_name':self.first_name,'last_name':self.last_name})) diff --git a/core/models/wallets.py b/core/models/wallets.py index e2d3b7a..0600572 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -11,6 +11,7 @@ from django.conf import settings from django.db import models from django.urls import reverse +#from troggle.core.models.survex import SurvexBlock # from troggle.core.models.troggle import DataIssue # circular import. Hmm class Wallet(models.Model): @@ -164,7 +165,8 @@ class Wallet(models.Model): return files def fixsurvextick(self, tick): - blocks = SurvexBlock.objects.filter(scanswallet = self) + blocks = self.survexblock_set.all() + #blocks = SurvexBlock.objects.filter(scanswallet = self) result = tick for b in blocks: if b.survexfile: # if any exist in db, no check for validity or a real file. Refactor. diff --git a/core/utils.py b/core/utils.py index 29c2643..5632440 100644 --- a/core/utils.py +++ b/core/utils.py @@ -34,7 +34,9 @@ save_carefully() - core function that saves troggle objects in the database various git add/commit functions that need refactoring together NOTE that TROG is not serialized! Two users can update it and conflict !! -This needs to be in a multi-user database with transactions. +This needs to be in a multi-user database with transactions. However it is +useful when doing a data import with databaseReset.py as that has a single +thread. ''' diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 6450753..c1ba965 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -15,7 +15,7 @@ from django.views.generic.list import ListView import troggle.settings as settings from troggle.core.models.logbooks import LogbookEntry, PersonTrip -from troggle.core.models.survex import SurvexBlock, Wallet +from troggle.core.models.survex import SurvexBlock from troggle.core.models.troggle import Expedition, Person, PersonExpedition from troggle.core.utils import TROG from troggle.parsers.imports import import_logbook diff --git a/media/css/trog3.css b/media/css/trog3.css index 990634a..e0097b9 100644 --- a/media/css/trog3.css +++ b/media/css/trog3.css @@ -71,15 +71,49 @@ table.expeditionpersonlist a:visited color:#509; } +table.expeditionpersonlist a.dayindexlog-0 +{ background-color: #af9; font-size: 130%;} table.expeditionpersonlist a.dayindexlog-1 -{ background-color: #440; color: white; } +{ background-color: #9af; font-size: 130%;} table.expeditionpersonlist a.dayindexlog-2 -{ background-color: #9fa; } -table.expeditionpersonlist a.dayindexsurvex-1 -{ background-color: #000; color: #55f; } -table.expeditionpersonlist a.dayindexsurvex-2 -{ background-color: #6ff; } +{ background-color: #880; color: white; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-3 +{ background-color: #f9a; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-4 +{ background-color: #808; color: white; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-5 +{ background-color: #088; color: white; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-6 +{ background-color: #000; color: yellow; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-7 +{ background-color: #a9f; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-8 +{ background-color: #fa9; font-size: 130%;} +table.expeditionpersonlist a.dayindexlog-9 +{ background-color: #9fa; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-0 +{ background-color: #f6f; font-size: 130%} +table.expeditionpersonlist a.dayindexsurvex-1 +{ background-color: #6ff; font-size: 130%} +table.expeditionpersonlist a.dayindexsurvex-2 +{ background-color: #ff6; font-size: 130%} +table.expeditionpersonlist a.dayindexsurvex-3 +{ background-color: #000; color: white; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-4 +{ background-color: #99f; color: white; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-5 +{ background-color: #f99; color: white; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-6 +{ background-color: #f99; color: yellow; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-7 +{ background-color: #f99; color: blue; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-8 +{ background-color: #9f9; color: blue; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-9 +{ background-color: #9f9; color: red; font-weight: bold; font-size: 130%;} +table.expeditionpersonlist a.dayindexsurvex-10 +{ background-color: #9f9; color: white; font-weight: bold; font-size: 130%;} table.expeditionpersonlist a:hover { color:white; diff --git a/parsers/survex.py b/parsers/survex.py index cce3905..634aeca 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -113,8 +113,10 @@ def put_person_on_trip(survexblock, personexpedition, tm): try: personrole = SurvexPersonRole.objects.create( - survexblock=survexblock, person = personexpedition.person, - expeditionday = survexblock.expeditionday, personexpedition=personexpedition, + survexblock=survexblock, + person = personexpedition.person, + # expeditionday = survexblock.expeditionday, + personexpedition=personexpedition, personname=tm ) except: @@ -353,14 +355,6 @@ class LoadingSurvex: expo = survexblock.expedition # may be None if no *date yet if expo: - if not survexblock.expeditionday: # *date has been set - # should not happen - message = f"! *team {expo.year} expo ok, expedition day NOT in *team {survexblock.survexfile.path} ({survexblock}) " - print(self.insp + message) - stash_data_issue( - parser="survex", message=message, url=None, sb=(survexblock.survexfile.path) - ) - personexpedition = GetPersonExpeditionNameLookup(expo).get(tm.lower()) if personexpedition: put_person_on_trip(survexblock, personexpedition, tm) @@ -501,7 +495,7 @@ class LoadingSurvex: expo = self.get_expo_from_year(year) survexblock.expedition = expo - survexblock.expeditionday = expo.get_expedition_day(survexblock.date) + # survexblock.expeditionday = expo.get_expedition_day(survexblock.date) survexblock.save() team = get_team_on_trip(survexblock) # should be empty, should only be in 'pending' @@ -1705,7 +1699,7 @@ class LoadingSurvex: stash_data_issue(parser="survex", message=message, url=None, sb=(path)) return # skip this survex file and all things *included in it except: - message = f" ! ERROR *include file '{path}' in '{survexblock}' has unexpected error. Omitted." + message = f" ! ERROR *include file '{path}' in '{survexblock}' has unexpected error. OMITTED!" print(message) print(message, file=sys.stderr) stash_data_issue(parser="survex", message=message, url=None, sb=(path)) diff --git a/templates/expedition.html b/templates/expedition.html index 92ebde7..dd4e7ab 100644 --- a/templates/expedition.html +++ b/templates/expedition.html @@ -27,8 +27,10 @@ {% endif %}

At a single glance: The table shows all expo cavers and their recorded trips. -The columns are the date in the month (July or August), with a "T" for a logbook entry, and -an "S" for a survey trip. The colours are the same for people on the same trip.

+The columns are the date in the month (July or August), with a +"T" for a logbook entry, and +an "S" for a survey trip. The colours are the same for people on the same trip.

+ @@ -47,7 +49,7 @@ an "S" for a survey trip. The colours are the same for people on the same trip. {% if persondayactivities.persontrips or persondayactivities.survexblocks %}
{% for persontrip in persondayactivities.persontrips %} - T + T {% endfor %}
{% for survexblock in persondayactivities.survexblocks %}