summaryrefslogtreecommitdiffstats
path: root/core/views/uploads.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-08-08 00:43:12 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-08-08 00:43:12 +0300
commitb1a5251768f05b1bcc97f287501c9a50d57e309d (patch)
tree1b1e7f9849b869c48430f5951c5837ec2ad04c25 /core/views/uploads.py
parent0b7a9cf03e2c9787388ea3847ab74bb438b02cde (diff)
downloadtroggle-b1a5251768f05b1bcc97f287501c9a50d57e309d.tar.gz
troggle-b1a5251768f05b1bcc97f287501c9a50d57e309d.tar.bz2
troggle-b1a5251768f05b1bcc97f287501c9a50d57e309d.zip
Format new logbook entry
Diffstat (limited to 'core/views/uploads.py')
-rw-r--r--core/views/uploads.py61
1 files changed, 51 insertions, 10 deletions
diff --git a/core/views/uploads.py b/core/views/uploads.py
index cdc633b..53c59cb 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -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