mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-24 16:21:53 +00:00
more debug for logbook edits
This commit is contained in:
parent
a2f4591f72
commit
ca103fde22
@ -230,7 +230,7 @@ def logentrydelete(request, year):
|
|||||||
print(f" - '{i}' {request.POST[i]}")
|
print(f" - '{i}' {request.POST[i]}")
|
||||||
eslug = request.POST["entry_slug"]
|
eslug = request.POST["entry_slug"]
|
||||||
entry = LogbookEntry.objects.get(slug=eslug)
|
entry = LogbookEntry.objects.get(slug=eslug)
|
||||||
# OK we delete it formt he db and then re-save logbook.html file
|
# OK we delete it from the db and then re-save logbook.html file
|
||||||
# to ensure that the permanent record also has the entry deleted.
|
# to ensure that the permanent record also has the entry deleted.
|
||||||
entry.delete()
|
entry.delete()
|
||||||
|
|
||||||
|
@ -291,6 +291,7 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
author = ""
|
author = ""
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
prev_slug = "" # None value pending overwrite from submitted form
|
||||||
form = LogbookEditForm(request.POST)
|
form = LogbookEditForm(request.POST)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
message = f'Invalid form response for logbook entry creating "{request.POST}"'
|
message = f'Invalid form response for logbook entry creating "{request.POST}"'
|
||||||
@ -306,8 +307,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()
|
||||||
if "slug" in request.POST:
|
if "prev_slug" in request.POST:
|
||||||
slug = request.POST["slug"].strip() # if we are re-editing the same entry again
|
prev_slug = request.POST["prev_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>
|
||||||
@ -335,15 +336,20 @@ 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 prev_slug and 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)
|
||||||
else:
|
|
||||||
|
if prev_slug and not slug:
|
||||||
|
# if this was a previous post, then prev_slug will have been set on the form
|
||||||
|
# we are editing a previous thing, so we don't create a new lbe
|
||||||
|
slug = prev_slug
|
||||||
|
|
||||||
# OK we could patch the object in place, but if the people on the trip have changed this
|
# OK we could patch the object in place, but if the people on the trip have changed this
|
||||||
# would get very messy. So we delete it and recreate it and all its links
|
# would get very messy. So we delete it, and thus all the dependent objects,
|
||||||
|
# and recreate it and all its links. It might not exist though.
|
||||||
print(f"- Deleting the LogBookEntry {slug}")
|
print(f"- Deleting the LogBookEntry {slug}")
|
||||||
LogbookEntry.objects.filter(slug=slug).delete()
|
LogbookEntry.objects.filter(slug=slug).delete() # works even if it does not exist
|
||||||
|
|
||||||
print(f"- Creating the LogBookEntry {slug}")
|
print(f"- Creating the LogBookEntry {slug}")
|
||||||
year = slug[0:4]
|
year = slug[0:4]
|
||||||
@ -440,7 +446,7 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
+ str(lbe_commit.returncode)
|
+ str(lbe_commit.returncode)
|
||||||
)
|
)
|
||||||
message = (
|
message = (
|
||||||
f"! - FORM Logbook Edit -Error code with git on server for {filename}. {slug} edits saved, added to git, but NOT committed.\n"
|
f"! - FORM Logbook Edit -Error code '{lbe_commit.returncode}' with git on server for {filename}. {slug} edits saved, added to git, but NOT committed.\n"
|
||||||
+ msgdata
|
+ msgdata
|
||||||
)
|
)
|
||||||
print(message)
|
print(message)
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<form method ='post' >
|
<form method ='post' >
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<br />
|
<br />
|
||||||
<input name="slug" id="slug" value="{{slug}}" type=hidden>
|
<input name="prev_slug" id="prev_slug" value="{{slug}}" type=hidden>
|
||||||
|
|
||||||
<span {% if dateflag %}style="color:red"{% endif %}>
|
<span {% if dateflag %}style="color:red"{% endif %}>
|
||||||
<label for="date">Date of the activity</label>
|
<label for="date">Date of the activity</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user