diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-26 19:23:07 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-26 19:23:07 +0000 |
commit | aef0de715d8c9768924fd3dfada037f48ac01a15 (patch) | |
tree | 8fb1f514631e9db910ff21bd192339d1c25f1b86 | |
parent | ce508b0eb28551efbb9d7aaf18f1e76994e7c38b (diff) | |
download | troggle-aef0de715d8c9768924fd3dfada037f48ac01a15.tar.gz troggle-aef0de715d8c9768924fd3dfada037f48ac01a15.tar.bz2 troggle-aef0de715d8c9768924fd3dfada037f48ac01a15.zip |
bugfix
-rw-r--r-- | core/utils.py | 2 | ||||
-rw-r--r-- | core/views/expo.py | 17 |
2 files changed, 14 insertions, 5 deletions
diff --git a/core/utils.py b/core/utils.py index d88f39f..d77c474 100644 --- a/core/utils.py +++ b/core/utils.py @@ -15,6 +15,8 @@ from pathlib import Path from django.contrib.auth.models import User from troggle.core.models.troggle import Expedition +from troggle.core.models.troggle import Person + getcontext().prec = 2 # use 2 significant figures for decimal calculations diff --git a/core/views/expo.py b/core/views/expo.py index 63f1d33..821decc 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -408,6 +408,9 @@ def getmimetype(path): def editexpopage(request, path): """Manages the 'Edit this Page' capability for expo handbook and other html pages. Relies on HTML5 or javascript to provide the in-browser editing environment. + + If the user is logged-on with a personal logon, then the Full Name and email + address for the git commit are taken from their stored details, not from any stored cookie. """ try: # if a cave not a webpage at all. @@ -466,8 +469,9 @@ def editexpopage(request, path): if request.method == "POST": # If the form has been submitted... pageform = ExpoPageForm(request.POST) # A form bound to the POST data if pageform.is_valid(): # Form valid therefore write file - editor = pageform.cleaned_data["who_are_you"] - editor = git_string(editor) + if not identified_login: + editor = pageform.cleaned_data["who_are_you"] + editor = git_string(editor) if filefound: headmatch = re.match(r"(.*)<title>.*</title>(.*)", head, re.DOTALL + re.IGNORECASE) if headmatch: @@ -497,8 +501,9 @@ def editexpopage(request, path): print(f"Cookie set: {editor} for {COOKIE_MAX_AGE/(24*3600)} days") try: change_message = pageform.cleaned_data["change_message"] - editor = pageform.cleaned_data["who_are_you"] - editor = git_string(editor) + if not identified_login: + editor = pageform.cleaned_data["who_are_you"] + editor = git_string(editor) write_and_commit([(filepath, result, "utf-8")], f"{change_message} - online edit of {path}", editor) except WriteAndCommitError as e: return render(request, "errors/generic.html", {"message": e.message}) @@ -514,8 +519,10 @@ def editexpopage(request, path): pageform = ExpoPageForm(initial={"identified_login": identified_login, "who_are_you":editor, "html": body, "title": title}) else: pageform = ExpoPageForm(initial={"identified_login": identified_login, "who_are_you":editor}) - + if identified_login: + # disable editing the git id string as we get it from the logged-on user data + pageform.fields["who_are_you"].widget.attrs["readonly"]="readonly" return render( request, "editexpopage.html", |