mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-24 16:21:53 +00:00
belt and braces prevent bad lbe ids
This commit is contained in:
parent
feaf38aa39
commit
07fc372b41
@ -306,7 +306,8 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
place = request.POST["place"].strip().replace(' - ',' = ') # no hyphens !
|
place = request.POST["place"].strip().replace(' - ',' = ') # no hyphens !
|
||||||
title = request.POST["title"].strip()
|
title = request.POST["title"].strip()
|
||||||
entry = request.POST["text"].strip()
|
entry = request.POST["text"].strip()
|
||||||
slug = request.POST["slug"].strip()
|
if "slug" in request.POST:
|
||||||
|
slug = request.POST["slug"].strip() # if we are re-editing the same entry again
|
||||||
entry = entry.replace('\r','') # remove HTML-standard CR inserted from form.
|
entry = entry.replace('\r','') # remove HTML-standard CR inserted from form.
|
||||||
entry = entry.replace('\n\n','\n<p>\n') # replace 2 \n with <br><br>
|
entry = entry.replace('\n\n','\n<p>\n') # replace 2 \n with <br><br>
|
||||||
# entry = entry.replace('\n\n','\n<br />\n<br />\n') # replace 2 \n with <br><br>
|
# entry = entry.replace('\n\n','\n<br />\n<br />\n') # replace 2 \n with <br><br>
|
||||||
@ -334,7 +335,7 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
authorflag = True
|
authorflag = True
|
||||||
print(f"! Unrecognised author: {author}")
|
print(f"! Unrecognised author: {author}")
|
||||||
|
|
||||||
|
# slug is set either because we already posted or because it was specified inthe url
|
||||||
if not slug:
|
if not slug:
|
||||||
# Creating a new logbook entry with all the gubbins
|
# Creating a new logbook entry with all the gubbins
|
||||||
slug = create_new_lbe_slug(date)
|
slug = create_new_lbe_slug(date)
|
||||||
|
@ -59,8 +59,8 @@ LOGBOOK_PARSER_SETTINGS = {
|
|||||||
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
|
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
|
||||||
|
|
||||||
ENTRIES = {
|
ENTRIES = {
|
||||||
"2024": 27,
|
"2024": 41,
|
||||||
"2023": 86,
|
"2023": 91,
|
||||||
"2022": 94,
|
"2022": 94,
|
||||||
"2019": 55,
|
"2019": 55,
|
||||||
"2018": 95,
|
"2018": 95,
|
||||||
@ -299,6 +299,11 @@ def store_entry_into_database(date, place, tripcave, title, text, trippersons, a
|
|||||||
def parser_date(tripdate, year):
|
def parser_date(tripdate, year):
|
||||||
"""Interprets dates in the expo logbooks and returns a correct datetime.date object
|
"""Interprets dates in the expo logbooks and returns a correct datetime.date object
|
||||||
Does NOT actually check that it is a truly valid date..
|
Does NOT actually check that it is a truly valid date..
|
||||||
|
|
||||||
|
tripdate : string
|
||||||
|
year : string
|
||||||
|
|
||||||
|
Nasty bug if it returns just the year which leads to a logbook id '/2023' instead of '/2023-07-16b'
|
||||||
"""
|
"""
|
||||||
dummydate = EPOCH
|
dummydate = EPOCH
|
||||||
month = 1
|
month = 1
|
||||||
@ -410,6 +415,13 @@ def parser_html(year, expedition, txt, seq=""):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
ldate = parser_date(tripdate.strip(), year)
|
ldate = parser_date(tripdate.strip(), year)
|
||||||
|
if len(str(ldate)) < 10:
|
||||||
|
ldate = date(year, 10, 1) # 1st October
|
||||||
|
msg = f" !- Logbook. Bad parsed date '{tripdate}' setting to '{ldate}'"
|
||||||
|
print(msg)
|
||||||
|
DataIssue.objects.create(parser="logbooks", message=msg)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
# Now we have a date, we can reset tripid
|
# Now we have a date, we can reset tripid
|
||||||
tid = reset_trip_id(ldate)
|
tid = reset_trip_id(ldate)
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
{% if tu %}value="{{tu}}"{% else %}placeholder="0.1" {% endif %}
|
{% if tu %}value="{{tu}}"{% else %}placeholder="0.1" {% endif %}
|
||||||
/>
|
/>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
<input type="hidden" value="{{slug}}" name="slug">
|
||||||
<button class="fancybutton2" style="padding: 0.5em 25px; margin-left: 110px" type = "submit" value = "save" >
|
<button class="fancybutton2" style="padding: 0.5em 25px; margin-left: 110px" type = "submit" value = "save" >
|
||||||
Update logbook entry
|
Update logbook entry
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user