summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/views/uploads.py45
1 files changed, 26 insertions, 19 deletions
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 9678c5c..ae8e69a 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -4,6 +4,7 @@ from pathlib import Path
from django import forms
from django.core.files.storage import FileSystemStorage
+from django.http import HttpResponseRedirect
from django.shortcuts import render, redirect
import settings
@@ -337,10 +338,13 @@ def logbookedit(request, year=None, slug=None):
print(f"! Unrecognised author: {author}")
# if somehow we get a slug set to just '2024', not eg '2020-08-10b'
+ # because the URL of the page is /logbookedit/2022 for a new entry
# This is a hack, why can we not reproduce this bug on the dev system?
- if len(slug) < 7:
+ if slug not in locals():
slug = ""
- if len(prev_slug) < 7:
+ if len(slug) < 11:
+ slug = ""
+ if len(prev_slug) < 11:
prev_slug = ""
if not prev_slug and not slug:
@@ -464,23 +468,26 @@ def logbookedit(request, year=None, slug=None):
# 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",
- {
- "form": form,
- "year": year,
- "date": date, "dateflag": dateflag,
- "author": author, "authorflag": authorflag,
- "others": others,
- "place": place,
- "title": title,
- "tu": tu,
- "entry": entry,
- "output": output,
- "slug": slug,
- },
- )
+ # logbookedit/2022-08-21a
+ return HttpResponseRedirect(f'/logbookedit/{slug}')
+
+ # return render(
+ # request,
+ # "logbookform.html",
+ # {
+ # "form": form,
+ # "year": year,
+ # "date": date, "dateflag": dateflag,
+ # "author": author, "authorflag": authorflag,
+ # "others": others,
+ # "place": place,
+ # "title": title,
+ # "tu": tu,
+ # "entry": entry,
+ # "output": output,
+ # "slug": slug,
+ # },
+ # )
# GET here
else:
form = LogbookEditForm()