2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 09:37:20 +00:00

Format new logbook entry

This commit is contained in:
2023-08-08 00:43:12 +03:00
parent 0b7a9cf03e
commit b1a5251768
2 changed files with 91 additions and 14 deletions

View File

@@ -63,16 +63,57 @@ def logbookedit(request, year=None):
author = "Zonker"
if not year:
year = 2023
form = LogbookEditForm()
return render(
request,
"logbookform.html",
{
"form": form,
"year": year,
"author": author,
},
)
if request.method == "POST":
form = LogbookEditForm(request.POST)
if not form.is_valid():
message = f'Invalid form response for logbook entry creating "{request.POST}"'
print(message)
return render(request, "errors/generic.html", {"message": message})
else:
# validation all to be done yet..
author = request.POST["author"]
date = request.POST["date"]
others = request.POST["others"]
place = request.POST["place"]
title = request.POST["title"]
entry = request.POST["text"]
tu = request.POST["tu"]
seq = 99
# OK this could be done by rendering a template, but for such a small bit of HTML, it is easier to have
# it all in one place: here
output = f'''
<hr />
<div class="tripdate" id="{date}-{seq}">{date}</div>
<div class="trippeople"><u>{author}</u>, {others}</div>
<div class="triptitle">{place} - {title}</div>
{entry}
<div class="timeug">T/U {tu} hrs</div>'''
return render(
request,
"logbookform.html",
{
"form": form,
"year": year,
"author": author,
"output": output,
},
)
# GET here
else:
form = LogbookEditForm()
return render(
request,
"logbookform.html",
{
"form": form,
"year": year,
"author": author,
},
)
@login_required_if_public