2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

Removed unused properties and moving

This commit is contained in:
Philip Sargent 2023-01-30 22:27:17 +00:00
parent 7808005498
commit e35fccea5d
5 changed files with 18 additions and 21 deletions

View File

@ -5,8 +5,8 @@
{"model": "core.personexpedition", "pk": 681, "fields":
{"new_since_parsing": false, "non_public": false,
"expedition": 44,
"person": 250, "slugfield": null, "is_guest": false,
"nickname": "Mike"}},
"person": 250, "slugfield": null, "is_guest": false
}},
{"model": "core.person", "pk": 250, "fields":
{"new_since_parsing": false, "non_public": false,

View File

@ -126,7 +126,6 @@ class SurvexBlock(models.Model):
name = models.CharField(max_length=100)
title = models.CharField(max_length=200)
parent = models.ForeignKey("SurvexBlock", 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)
expedition = models.ForeignKey("Expedition", blank=True, null=True, on_delete=models.SET_NULL)
@ -169,9 +168,8 @@ class SurvexPersonRole(models.Model):
survexblock = models.ForeignKey("SurvexBlock", on_delete=models.CASCADE)
# increasing levels of precision, Surely we only need survexblock and person now that we have no link to a logbook entry?
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) # not needed
personexpedition = models.ForeignKey("PersonExpedition", blank=True, null=True, on_delete=models.SET_NULL)
# expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)
def __str__(self):
return str(self.personname) + " - " + str(self.survexblock)

View File

@ -154,6 +154,14 @@ class Person(TroggleModel):
def last(self):
return self.personexpedition_set.order_by("expedition")[0]
# moved from personexpedition
def name(self):
if self.nickname:
return f"{self.first_name} ({self.nickname}) {self.last_name}"
if self.last_name:
return f"{self.first_name} {self.last_name}"
return self.first_name
class PersonExpedition(TroggleModel):
"""Person's attendance to one Expo"""
@ -163,7 +171,6 @@ 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) # removbe this
class Meta:
ordering = ("-expedition",)
@ -172,13 +179,6 @@ class PersonExpedition(TroggleModel):
def __str__(self):
return f"{self.person}: ({self.expedition})"
# why is the below a function in personexpedition, rather than in person? - AC 14 Feb 09
def name(self):
if self.nickname:
return f"{self.person.first_name} ({self.nickname}) {self.person.last_name}"
if self.person.last_name:
return f"{self.person.first_name} {self.person.last_name}"
return self.person.first_name
def get_absolute_url(self):
return urljoin(

View File

@ -89,7 +89,7 @@ def load_people_expos():
name = re.sub(r"<.*?>", "", name)
firstname = ""
nickname = ""
nick = ""
rawlastname = personline[header["Lastname"]].strip()
matchlastname = re.match(r"^([\w&;\s]+)(?:\(([^)]*)\))?", rawlastname)
@ -98,7 +98,7 @@ def load_people_expos():
splitnick = re.match(r"^([\w&;\s]+)(?:\(([^)]*)\))?", name)
fullname = splitnick.group(1)
nickname = splitnick.group(2) or ""
nick = splitnick.group(2) or ""
fullname = fullname.strip()
names = fullname.split(" ")
@ -112,7 +112,7 @@ def load_people_expos():
vfho = True
lookupAttribs = {"first_name": firstname, "last_name": (lastname or "")}
nonLookupAttribs = {"is_vfho": vfho, "fullname": fullname, "nickname": nickname}
nonLookupAttribs = {"is_vfho": vfho, "fullname": fullname, "nickname": nick}
person = Person.objects.create(**nonLookupAttribs, **lookupAttribs)
parse_blurb(personline=personline, header=header, person=person)
@ -122,7 +122,7 @@ def load_people_expos():
expedition = Expedition.objects.get(year=year)
if attended == "1" or attended == "-1":
lookupAttribs = {"person": person, "expedition": expedition}
nonLookupAttribs = {"nickname": nickname, "is_guest": (personline[header["Guest"]] == "1")}
nonLookupAttribs = {"is_guest": (personline[header["Guest"]] == "1")}
pe = PersonExpedition.objects.create(**nonLookupAttribs, **lookupAttribs)
print("", flush=True)
@ -214,7 +214,7 @@ def GetPersonExpeditionNameLookup(expedition):
f = unidecode(unescape(personexpedition.person.first_name.lower()))
l = unidecode(unescape(personexpedition.person.last_name.lower()))
full = unidecode(unescape(personexpedition.person.fullname.lower()))
n = unidecode(unescape(personexpedition.nickname.lower()))
n = unidecode(unescape(personexpedition.person.nickname.lower()))
if full not in possnames:
possnames.append(full)
if n not in possnames:

View File

@ -1390,7 +1390,6 @@ class LoadingSurvex:
name=blkid,
parent=survexblock,
survexpath=pathlist,
cave=self.currentcave,
survexfile=self.currentsurvexfile,
legsall=0,
legslength=0.0,
@ -2050,7 +2049,7 @@ def LoadSurvexBlocks():
survexfileroot = MakeSurvexFileRoot()
# this next makes a block_object assciated with a file_object.path = SURVEX_TOPNAME
survexblockroot = SurvexBlock(
name=ROOTBLOCK, survexpath="", cave=None, survexfile=survexfileroot, legsall=0, legslength=0.0
name=ROOTBLOCK, survexpath="", survexfile=survexfileroot, legsall=0, legslength=0.0
)
# crashes here sometimes on MariaDB complaining that cave_id should not be null. But it should be.
# django.db.utils.IntegrityError: (1048, "Column 'cave_id' cannot be null")
@ -2061,7 +2060,7 @@ def LoadSurvexBlocks():
omitsfileroot = MakeOmitFileRoot("_unseens.svx")
survexomitsroot = SurvexBlock(
name=OMITBLOCK, survexpath="", cave=None, survexfile=omitsfileroot, legsall=0, legslength=0.0
name=OMITBLOCK, survexpath="", survexfile=omitsfileroot, legsall=0, legslength=0.0
)
survexomitsroot.save()