From c01f0e1dff515ff40390e618d05c2712488b755a Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 23 Jul 2024 08:58:17 +0200 Subject: [PATCH] debug stuff for logreport --- core/views/uploads.py | 15 ++++++++++++--- templates/logbookform.html | 3 ++- templates/logreport.html | 8 +++++--- 3 files changed, 19 insertions(+), 7 deletions(-) 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 @@

{% csrf_token %}
- + + (Hover mouse over the date to see the slug for the entry.) {% if logged_in %}Logged in as expoadmin{% endif %} - + -{% if logged_in %}{% endif %} +{% if logged_in %}{% endif %} {% regroup dateditems|dictsort:"date" by date as dates %} {% for date in dates %} @@ -61,7 +61,9 @@ {% if logged_in %} {% csrf_token %} - + {% endif %}
DateLogged trips and diary entriesCaveText..WordsAuthorWho elseAdminSlugAdmin
+ +{{entry.slug}}