mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
Format new logbook entry
This commit is contained in:
parent
0b7a9cf03e
commit
b1a5251768
@ -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
|
||||
|
@ -13,7 +13,9 @@
|
||||
</p>
|
||||
{% endif %}
|
||||
<style>
|
||||
input, textarea {font-family: monospace; font-weight: bold; text-align:center; font-size: 100%; padding: 0.5em; }
|
||||
input, textarea, pre {font-family: monospace; font-weight: bold; text-align:center; font-size: 100%; padding: 0.5em; }
|
||||
textarea {text-align:left }
|
||||
pre {text-align:left; font-size: 120% }
|
||||
textarea {text-align:left }
|
||||
</style>
|
||||
<div style = "max-width:100%; margin-left:15%; font-family: monospace; font-weight: bold; font-size: 150%; text-align: right; " >
|
||||
@ -67,9 +69,9 @@
|
||||
label = "tu" name = "tu" size="5"
|
||||
title="Time underground (hours)"
|
||||
placeholder="0.1" />
|
||||
<br /><br /> <span style="color: red">This DOES NOT WORK yet</span>
|
||||
<br /><br /> <span style="color: red">This DOES NOT SAVE ANYTHING yet</span>
|
||||
<button class="fancybutton2" style="padding: 0.5em 25px; margin-left: 110px" type = "submit" value = "save" >
|
||||
Save logbook entry
|
||||
Do logbook entry
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@ -82,5 +84,39 @@
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
{% 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.
|
||||
<pre>
|
||||
{{output}}
|
||||
</pre>
|
||||
<hr>
|
||||
<style>
|
||||
.tripdate, .trippeople {
|
||||
background-color: #C6E4E3;
|
||||
float: left;
|
||||
margin: 2px 1px 1px 1px;
|
||||
padding: 10px;
|
||||
border-bottom-right-radius: 1em;
|
||||
}
|
||||
.trippeople {
|
||||
background-color: #fff;
|
||||
float: right;
|
||||
font-style: italic;
|
||||
}
|
||||
.triptitle {
|
||||
border: 1px solid #99CCCC;
|
||||
border-top-width: 2px;
|
||||
color: #008787;
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
padding: 45px 10px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.timeug {
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;}
|
||||
</style>
|
||||
{{output|safe}}
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user