mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
Keeping *person and guests such as Karl in the list
This commit is contained in:
parent
ac128705f6
commit
2506517e17
@ -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,32 +94,41 @@ 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:
|
||||||
try:
|
if name[0] == "*": # a name prefix of "*" is special, just a string.
|
||||||
personyear = GetPersonExpeditionNameLookup(expedition).get(name.lower())
|
odds.append(name)
|
||||||
if not personyear:
|
else:
|
||||||
if known_foreigner(name):
|
try:
|
||||||
message = f" ! - Known foreigner: '{name}' in entry {slug=}"
|
personyear = GetPersonExpeditionNameLookup(expedition).get(name.lower())
|
||||||
print(message)
|
if not personyear:
|
||||||
else:
|
odds.append(name)
|
||||||
message = f" ! - No name match for: '{name}' in entry {slug=}"
|
if known_foreigner(name):
|
||||||
print(message)
|
message = f" ! - Known foreigner: '{name}' in entry {slug=}"
|
||||||
DataIssue.objects.create(parser="logbooks", message=message)
|
print(message)
|
||||||
else:
|
else:
|
||||||
lookupAttribs = {"personexpedition": personyear, "nickname_used": name, "logbook_entry": lbo} # lbo is primary key
|
message = f" ! - No name match for: '{name}' in entry {slug=}"
|
||||||
nonLookupAttribs = {"time_underground": tu, "is_logbook_entry_author": (name==author)}
|
print(message)
|
||||||
pt_list.append(PersonLogEntry(**nonLookupAttribs, **lookupAttribs))
|
DataIssue.objects.create(parser="logbooks", message=message)
|
||||||
|
else:
|
||||||
|
lookupAttribs = {"personexpedition": personyear, "nickname_used": name, "logbook_entry": lbo} # lbo is primary key
|
||||||
|
nonLookupAttribs = {"time_underground": tu, "is_logbook_entry_author": (name==author)}
|
||||||
|
pt_list.append(PersonLogEntry(**nonLookupAttribs, **lookupAttribs))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
# This should not happen. We do not raise exceptions in that function
|
# This should not happen. We do not raise exceptions in that function
|
||||||
message = f" ! - EXCEPTION: '{name}' in entry {slug=}"
|
message = f" ! - EXCEPTION: '{name}' in entry {slug=}"
|
||||||
print(message)
|
print(message)
|
||||||
DataIssue.objects.create(parser="logbooks", message=message)
|
DataIssue.objects.create(parser="logbooks", message=message)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user