diff --git a/core/models/troggle.py b/core/models/troggle.py
index a9103bb..7e02a8c 100644
--- a/core/models/troggle.py
+++ b/core/models/troggle.py
@@ -100,7 +100,7 @@ class Person(TroggleModel):
default=False,
)
is_guest = models.BooleanField(default=False) # This is per-Person, not per-PersonExpedition
- mug_shot = models.CharField(max_length=100, blank=True, null=True)
+ mugshot = models.CharField(max_length=100, blank=True, null=True)
blurbfile = models.CharField(max_length=100, blank=True, null=True)
blurb = models.TextField(blank=True, null=True)
orderref = models.CharField(max_length=200, blank=True) # for alphabetic
diff --git a/core/views/other.py b/core/views/other.py
index a11ef97..862d278 100644
--- a/core/views/other.py
+++ b/core/views/other.py
@@ -163,7 +163,7 @@ def folk_export(request):
newfile = settings.EXPOWEB / 'folk' / 'new_folk.csv'
with open(newfile, 'w') as f:
- f.write("Name,Lastname,Guest,VfHO member,Mugshot")
+ f.write("Name,Lastname,Guest,VfHO member,Mugshot,Blurbfile")
for y in yearlist:
try:
expo[y] = Expedition.objects.get(year=y)
@@ -184,9 +184,11 @@ def folk_export(request):
f.write(",1")
else:
f.write(",")
- if person.mug_shot:
- f.write(f",{person.mug_shot.replace("/folk/","")}")
- elif person.blurbfile:
+ if person.mugshot:
+ f.write(f",{person.mugshot.replace("/folk/","")}")
+ else:
+ f.write(",")
+ if person.blurbfile:
f.write(f",{person.blurbfile.replace("/folk/","")}")
else:
f.write(",")
diff --git a/parsers/people.py b/parsers/people.py
index e838237..1006c27 100644
--- a/parsers/people.py
+++ b/parsers/people.py
@@ -24,50 +24,44 @@ todo = """
"""
def parse_blurb(personline, header):
- """create mugshot Photo instance
- Would be better if all this was done before the Person object was created in the db, then it would not
- need re-saving (which is slow)"""
+ """Read the mugshot and blurbfile strings and checks that
+ the correspond to real files.
+
+ Fixes the format of tags inside a blurbfile
+ and loads the resulting blurb into the database"""
person = {}
- ms_filename = personline[header["Mugshot"]]
- ms_path = Path(settings.EXPOWEB, "folk", ms_filename)
+
+ for folk_field in ["Mugshot", "Blurbfile"]:
+
+ ms_filename = personline[header[folk_field]]
+ ms_path = settings.EXPOWEB / "folk" / ms_filename
- if ms_filename:
- if not ms_path.is_file():
- message = f"! INVALID mug_shot field '{ms_filename}' for {personline[header["Mugshot"]]}"
- print(message)
- DataIssue.objects.create(parser="people", message=message, url=f"/person/{personline[header["fullname"]]}")
- return
+ if ms_filename:
+ if not ms_path.is_file():
+ message = f"! INVALID {folk_field} field '{ms_filename}' for {personline[header[folk_field]]}"
+ print(message)
+ DataIssue.objects.create(parser="people", message=message, url=f"/person/{personline[header["Name"]]}")
+ return
- if ms_filename.startswith("i/"):
- # if person just has an image, add it. It has format 'i/adama2018.jpg'
- person["mug_shot"] = str(Path("/folk", ms_filename))
- person["blurb"] = None
- elif ms_filename.startswith("l/"):
- # it has the format 'l/ollybetts.htm' the file may contain
images
- person["blurbfile"] = str(Path("/folk", ms_filename))
- with open(ms_path, "r") as blurbfile:
- blrb = blurbfile.read()
- pblurb = re.search(r"
images
+ print(f"{personline[header["Name"]]}\n-- {folk_field} -- {ms_path}")
+ with open(ms_path, "r") as blurbfile:
+ blrb = blurbfile.read()
+ pblurb = re.search(r".*