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:
|
|
||||||
# OK we could patch the object in place, but if the people on the trip have changed this
|
if prev_slug and not slug:
|
||||||
# would get very messy. So we delete it and recreate it and all its links
|
# if this was a previous post, then prev_slug will have been set on the form
|
||||||
print(f"- Deleting the LogBookEntry {slug}")
|
# we are editing a previous thing, so we don't create a new lbe
|
||||||
LogbookEntry.objects.filter(slug=slug).delete()
|
slug = prev_slug
|
||||||
|
|
||||||
|
# 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 thus all the dependent objects,
|
||||||
|
# and recreate it and all its links. It might not exist though.
|
||||||
|
print(f"- Deleting the LogBookEntry {slug}")
|
||||||
|
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]
|
||||||
@ -351,13 +357,13 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
expedition = Expedition.objects.get(year=year)
|
expedition = Expedition.objects.get(year=year)
|
||||||
except Expedition.DoesNotExist:
|
except Expedition.DoesNotExist:
|
||||||
message = f'''! - This expo "{year}" not created yet
|
message = f'''! - This expo "{year}" not created yet
|
||||||
It needs to be created before you can save a logbook entry.
|
It needs to be created before you can save a logbook entry.
|
||||||
See /handbook/computing/newyear.html
|
See /handbook/computing/newyear.html
|
||||||
|
|
||||||
WHAT TO DO NOW:
|
WHAT TO DO NOW:
|
||||||
1. Press the Back button on your proswer to return to the screen where you typed up the entry,
|
1. Press the Back button on your proswer to return to the screen where you typed up the entry,
|
||||||
2. Copy the text of what you wrote into a new text file,
|
2. Copy the text of what you wrote into a new text file,
|
||||||
3. Direct a nerd to fix this. It should take only a couple of minutes.'''
|
3. Direct a nerd to fix this. It should take only a couple of minutes.'''
|
||||||
print(message)
|
print(message)
|
||||||
return render(request, "errors/generic.html", {"message": message})
|
return render(request, "errors/generic.html", {"message": message})
|
||||||
store_edited_entry_into_database(date, place, title, entry, others, author, tu, slug)
|
store_edited_entry_into_database(date, place, title, entry, others, author, tu, slug)
|
||||||
@ -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