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

Keeping *person and guests such as Karl in the list

This commit is contained in:
Philip Sargent 2023-09-04 20:12:09 +03:00
parent ac128705f6
commit 2506517e17

View File

@ -60,6 +60,8 @@ def create_new_lbe_slug(date):
def store_edited_entry_into_database(date, place, title, text, others, author, tu, slug):
"""saves a single logbook entry and related personlogentry items
need to select out *guest and foreign friends from others
Rather similar to similarly named function in parsers/logbooks but circular reference prevents us using it directly,
and they need refactoring anyway.
"""
@ -81,7 +83,8 @@ def store_edited_entry_into_database(date, place, title, text, others, author, t
"expedition": expedition,
"time_underground": tu,
"cave_slug": str(cave),
"title": f"{place} - {title}"
"title": f"{place} - {title}",
# "other_people": others
}
lookupAttribs = {"slug": slug, "date": date }
@ -91,12 +94,18 @@ def store_edited_entry_into_database(date, place, title, text, others, author, t
# These entities have to be PersonExpedition objects
team = others.split(",")
team.append(author)
odds = []
for name in team:
name = name.strip()
if len(name) > 0 and name[0] != "*": # a name prefix of "*" is special, just a string.
if len(name) > 0:
if name[0] == "*": # a name prefix of "*" is special, just a string.
odds.append(name)
else:
try:
personyear = GetPersonExpeditionNameLookup(expedition).get(name.lower())
if not personyear:
odds.append(name)
if known_foreigner(name):
message = f" ! - Known foreigner: '{name}' in entry {slug=}"
print(message)
@ -118,6 +127,9 @@ def store_edited_entry_into_database(date, place, title, text, others, author, t
PersonLogEntry.objects.bulk_create(pt_list)
lbo.other_people = ", ".join(odds)
lbo.save()
class FilesForm(forms.Form): # not a model-form, just a form-form
uploadfiles = forms.FileField()
@ -204,7 +216,7 @@ def logbookedit(request, year=None, slug=None):
print(f"- Rewriting the entire {year} logbook to disc ")
filename= "logbook.html"
try:
writelogbook(year, filename) # uses a template, not the code fragment below
writelogbook(year, filename) # uses a template, not the code fragment below which is just a visible hint to logged on user
except:
message = f'! - Logbook saving failed - \n!! Permissions failure ?! on attempting to save file "logbook.html"'
print(message)