From b1a5251768f05b1bcc97f287501c9a50d57e309d Mon Sep 17 00:00:00 2001
From: Philip Sargent
Date: Tue, 8 Aug 2023 00:43:12 +0300
Subject: [PATCH] Format new logbook entry
---
core/views/uploads.py | 61 +++++++++++++++++++++++++++++++-------
templates/logbookform.html | 44 ++++++++++++++++++++++++---
2 files changed, 91 insertions(+), 14 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'''
+
+
This DOES NOT SAVE ANYTHING yet
@@ -82,5 +84,39 @@
-
+{% if output %}
+This is the HTML which will be put into the logbook.html, and below that is the HTML as rendered to be read as part of the full logbook.
+
+{{output}}
+
+
+
+{{output|safe}}
+{% endif %}
{% endblock %}
\ No newline at end of file