2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Remove unneeded Class ExpeditionDay

This commit is contained in:
Philip Sargent 2023-01-30 16:42:56 +00:00
parent ebe86d73d4
commit a12f666e96
6 changed files with 20 additions and 67 deletions

View File

@ -120,7 +120,6 @@ class SurvexBlock(models.Model):
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL) cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
date = models.DateField(blank=True, null=True) date = models.DateField(blank=True, null=True)
#expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)
expedition = models.ForeignKey('Expedition', blank=True, 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) survexfile = models.ForeignKey("SurvexFile", blank=True, null=True,on_delete=models.SET_NULL)
@ -162,7 +161,7 @@ class SurvexPersonRole(models.Model):
personname = models.CharField(max_length=100) personname = models.CharField(max_length=100)
person = models.ForeignKey('Person', blank=True, null=True,on_delete=models.SET_NULL) 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) personexpedition = models.ForeignKey('PersonExpedition', blank=True, null=True,on_delete=models.SET_NULL)
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL) # expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)
def __str__(self): def __str__(self):
return str(self.personname) + " - " + str(self.survexblock) return str(self.personname) + " - " + str(self.survexblock)

View File

@ -84,14 +84,14 @@ class Expedition(TroggleModel):
return urljoin(settings.URL_ROOT, reverse('expedition', args=[self.year])) return urljoin(settings.URL_ROOT, reverse('expedition', args=[self.year]))
class ExpeditionDay(TroggleModel): # class ExpeditionDay(TroggleModel):
"""Exists only on Expedition now. Removed links from logbookentry, personlogentry, survex stuff etc. # """Exists only on Expedition now. Removed links from logbookentry, personlogentry, survex stuff etc.
""" # """
expedition = models.ForeignKey("Expedition",on_delete=models.CASCADE) # expedition = models.ForeignKey("Expedition",on_delete=models.CASCADE)
date = models.DateField() # date = models.DateField()
class Meta: # class Meta:
ordering = ('date',) # ordering = ('date',)
class Person(TroggleModel): class Person(TroggleModel):

View File

@ -103,7 +103,7 @@ def expedition(request, expeditionname):
allpersonlogentries = PersonLogEntry.objects.filter(personexpedition__expedition=expo) allpersonlogentries = PersonLogEntry.objects.filter(personexpedition__expedition=expo)
personexpeditiondays = [ ] personexpodays = [ ]
for personexpedition in expo.personexpedition_set.all(): for personexpedition in expo.personexpedition_set.all():
expotrips = allpersonlogentries.filter(personexpedition=personexpedition) # lazy expotrips = allpersonlogentries.filter(personexpedition=personexpedition) # lazy
expoblocks = blocks.filter(survexpersonrole__personexpedition=personexpedition) expoblocks = blocks.filter(survexpersonrole__personexpedition=personexpedition)
@ -119,12 +119,12 @@ def expedition(request, expeditionname):
if issunday := (date.weekday() == 6): # WALRUS if issunday := (date.weekday() == 6): # WALRUS
pcell["sunday"] = issunday pcell["sunday"] = issunday
prow.append(pcell) prow.append(pcell)
personexpeditiondays.append({"personexpedition":personexpedition, "personrow":prow}) personexpodays.append({"personexpedition":personexpedition, "personrow":prow})
ts[expeditionname] = {'expedition': expo, ts[expeditionname] = {'expedition': expo,
'expeditions':expeditions, 'expeditions':expeditions,
'personexpeditiondays':personexpeditiondays, 'settings':settings, 'personexpodays':personexpodays, 'settings':settings,
'dateditems': dateditems, 'dates':dates} 'dateditems': dateditems, 'dates':dates}
TROG['pagecache']['expedition'][expeditionname] = ts[expeditionname] TROG['pagecache']['expedition'][expeditionname] = ts[expeditionname]
@ -219,15 +219,10 @@ 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 = Expedition.objects.get(year=int(date[0:4]))
# if thisexpo:
# #expeditionday = thisexpo.get_expedition_day(date)
# svxothers = SurvexBlock.objects.filter(date=date)
# else:
# svxothers = None
svxothers = SurvexBlock.objects.filter(date=date) svxothers = SurvexBlock.objects.filter(date=date)
this_logbookentry=this_logbookentry[0] this_logbookentry=this_logbookentry[0]
# This is the only page that uses personlogentry_next and personlogentry_prev # This is the only page that uses next_.. and prev_..
# and it is calculated on the fly in the model # and it is calculated on the fly in the model
return render(request, 'logbookentry.html', return render(request, 'logbookentry.html',
{'logbookentry': this_logbookentry, 'trips': trips, 'svxothers': svxothers, 'wallets': wallets}) {'logbookentry': this_logbookentry, 'trips': trips, 'svxothers': svxothers, 'wallets': wallets})

View File

@ -212,15 +212,9 @@ def tidy_tid(tid, title):
return tid return tid
def store_entry_into_database(date, place, tripcave, title, text, trippersons, author, expedition, logtime_underground, tid): def store_entry_into_database(date, place, tripcave, title, text, trippersons, author, expedition, logtime_underground, tid):
"""saves a single logbook entry and related personlogentrys """saves a single logbook entry and related personlogentry items
Does NOT save the expeditionday_id - all NULLs. why? Because we are deprecating expeditionday !
""" """
# gets the current ExpeditionDay, and saves it as an object attached to
# the expedition, but does not attach it to the logbook entry. Why ?
# expedition.get_expedition_day(date)
nonLookupAttribs = { nonLookupAttribs = {
"place": place, "place": place,
"text": text, "text": text,

View File

@ -117,7 +117,6 @@ def put_person_on_trip(survexblock, personexpedition, tm):
personrole = SurvexPersonRole.objects.create( personrole = SurvexPersonRole.objects.create(
survexblock=survexblock, survexblock=survexblock,
person = personexpedition.person, person = personexpedition.person,
# expeditionday = survexblock.expeditionday,
personexpedition=personexpedition, personexpedition=personexpedition,
personname=tm personname=tm
) )
@ -497,7 +496,6 @@ class LoadingSurvex:
expo = self.get_expo_from_year(year) expo = self.get_expo_from_year(year)
survexblock.expedition = expo survexblock.expedition = expo
# survexblock.expeditionday = expo.get_expedition_day(survexblock.date)
survexblock.save() survexblock.save()
team = get_team_on_trip(survexblock) # should be empty, should only be in 'pending' team = get_team_on_trip(survexblock) # should be empty, should only be in 'pending'
@ -526,44 +524,11 @@ class LoadingSurvex:
message=message, message=message,
url=None, sb=(survexblock.survexfile.path), url=None, sb=(survexblock.survexfile.path),
) )
# All this next section should not happen unless there are >1 *date lines in a block
# for pr in team: # pr is a PersonRole object
# if not pr.expeditionday: # *date and *team in 'wrong' order.
# pr.expeditionday = survexblock.expeditionday
# pr.save()
# if not pr.personexpedition:
# pe = GetPersonExpeditionNameLookup(expo).get(pr.personname.lower())
# if pe: # pe is a PersonExpedition
# # message = "! {} ({}) Fixing undated personexpedition '{}'".format(survexblock.survexfile.path, survexblock, p.personname)
# # print(self.insp+message)
# # stash_data_issue(parser='survex', message=message)
# pr.personexpedition = pe
# pr.person = pr.personexpedition.person
# pr.save()
# elif known_foreigner(pr.personname): # note, not using .lower()
# message = f"- *team {expo.year} '{pr.personname}' known foreigner on *date {survexblock.survexfile.path} ({survexblock}) in '{line}'"
# print(self.insp + message)
# # stash_data_issue(parser='survex', message=message, url=None, sb=(survexblock.survexfile.path))
# else:
# message = f"! *team {year} '{pr.personname}' FAIL personexpedition lookup on *date {survexblock.survexfile.path} ({survexblock}) '{pr.personname}'"
# print(self.insp + message)
# stash_data_issue(
# parser="survex",
# message=message,
# url=None, sb=(survexblock.survexfile.path),
# )
oline = line oline = line
if len(line) > 10: if len(line) > 10:
# message = "! DATE Warning LONG DATE '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path) message = "! DATE Warning LONG DATE '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path)
# print(self.insp+message) print(self.insp+message)
# stash_data_issue(parser='survex', message=message, url=None, sb=(survexblock.survexfile.path)) stash_data_issue(parser='survex', message=message, url=None, sb=(survexblock.survexfile.path))
if line[10] == "-": # ie a range, just look at first date if line[10] == "-": # ie a range, just look at first date
line = line[0:10] line = line[0:10]
if len(line) == 10: if len(line) == 10:

View File

@ -41,10 +41,10 @@ an "<b>S</b>" for a survey trip. The colours of the "<b>T</b>" and "<b>S</b>" a
</th> </th>
{% endfor %} {% endfor %}
</tr> </tr>
{% for personexpeditionday in personexpeditiondays %} {% for personexpoday in personexpodays %}
<tr> <tr>
<td><a href="{{ personexpeditionday.personexpedition.get_absolute_url }}">{{personexpeditionday.personexpedition.person|safe}}</a></td> <td><a href="{{ personexpoday.personexpedition.get_absolute_url }}">{{personexpoday.personexpedition.person|safe}}</a></td>
{% for activities in personexpeditionday.personrow %} {% for activities in personexpoday.personrow %}
{% if activities.personentries or activities.survexblocks %} {% if activities.personentries or activities.survexblocks %}
<td class="persondayactivity"> <td class="persondayactivity">