2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-04-04 01:41:44 +01: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): def store_edited_entry_into_database(date, place, title, text, others, author, tu, slug):
"""saves a single logbook entry and related personlogentry items """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, Rather similar to similarly named function in parsers/logbooks but circular reference prevents us using it directly,
and they need refactoring anyway. and they need refactoring anyway.
""" """
@ -81,7 +83,8 @@ def store_edited_entry_into_database(date, place, title, text, others, author, t
"expedition": expedition, "expedition": expedition,
"time_underground": tu, "time_underground": tu,
"cave_slug": str(cave), "cave_slug": str(cave),
"title": f"{place} - {title}" "title": f"{place} - {title}",
# "other_people": others
} }
lookupAttribs = {"slug": slug, "date": date } 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 # These entities have to be PersonExpedition objects
team = others.split(",") team = others.split(",")
team.append(author) team.append(author)
odds = []
for name in team: for name in team:
name = name.strip() 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: try:
personyear = GetPersonExpeditionNameLookup(expedition).get(name.lower()) personyear = GetPersonExpeditionNameLookup(expedition).get(name.lower())
if not personyear: if not personyear:
odds.append(name)
if known_foreigner(name): if known_foreigner(name):
message = f" ! - Known foreigner: '{name}' in entry {slug=}" message = f" ! - Known foreigner: '{name}' in entry {slug=}"
print(message) 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) 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 class FilesForm(forms.Form): # not a model-form, just a form-form
uploadfiles = forms.FileField() uploadfiles = forms.FileField()
@ -204,7 +216,7 @@ def logbookedit(request, year=None, slug=None):
print(f"- Rewriting the entire {year} logbook to disc ") print(f"- Rewriting the entire {year} logbook to disc ")
filename= "logbook.html" filename= "logbook.html"
try: 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: except:
message = f'! - Logbook saving failed - \n!! Permissions failure ?! on attempting to save file "logbook.html"' message = f'! - Logbook saving failed - \n!! Permissions failure ?! on attempting to save file "logbook.html"'
print(message) print(message)