diff --git a/core/views/uploads.py b/core/views/uploads.py index 8cd6704..c58bc65 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -51,7 +51,10 @@ def create_new_lbe_slug(date): suffix = alphabet_suffix(n+1) tid = f"{date}{suffix}" - print(tid) + if len(tid) <=4 : + print(f"BAD ERROR {tid=}") + tid = f"{date}_{LogbookEntry.objects.count()}_{n}" # fudged number + print(f"{tid=}") return tid def store_edited_entry_into_database(date, place, title, text, others, author, tu, slug): @@ -275,7 +278,7 @@ def logbookedit(request, year=None, slug=None): return tu if not year: - if not slug: + if not slug: # not in the URL, we have not read teh POST response yet.. wich might have a slug in it year = current_expo() else: year = slug[0:4] @@ -303,6 +306,7 @@ def logbookedit(request, year=None, slug=None): place = request.POST["place"].strip().replace(' - ',' = ') # no hyphens ! title = request.POST["title"].strip() entry = request.POST["text"].strip() + slug = request.POST["slug"].strip() entry = entry.replace('\r','') # remove HTML-standard CR inserted from form. entry = entry.replace('\n\n','\n
\n') # replace 2 \n with
# entry = entry.replace('\n\n','\n
\n
\n') # replace 2 \n with
@@ -439,8 +443,13 @@ def logbookedit(request, year=None, slug=None):
+ msgdata
)
print(message)
- return render(request, "errors/generic.html", {"message": message})
+ if not (lbe_commit.returncode ==1 and settings.DEVSERVER):
+ # rc=1 is OK on the development server
+ return render(request, "errors/generic.html", {"message": message})
+ # This does not change the URL in the browser, so despite a new slug being created,
+ # the next time this code is run it thinks a new slug needs to be created. So we should
+ # actually redirect to a new URL (an edit not a create) not simply return a render object.
return render(
request,
"logbookform.html",
diff --git a/templates/logbookform.html b/templates/logbookform.html
index c10efb7..399ec2d 100644
--- a/templates/logbookform.html
+++ b/templates/logbookform.html
@@ -29,7 +29,8 @@