summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2025-02-13 16:42:51 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2025-02-13 16:42:51 +0000
commita976497b3a10bbc75fbb8a358a6fd7e389e87214 (patch)
tree52a854ef709b66867da82539ccfe83e4d4f6adf3
parent3fb99eb4be5f1c3199bdc2bab3c81f3195bf8710 (diff)
downloadtroggle-a976497b3a10bbc75fbb8a358a6fd7e389e87214.tar.gz
troggle-a976497b3a10bbc75fbb8a358a6fd7e389e87214.tar.bz2
troggle-a976497b3a10bbc75fbb8a358a6fd7e389e87214.zip
text file editor now using validated logon properly
-rw-r--r--core/views/expo.py3
-rw-r--r--core/views/uploads.py13
-rw-r--r--templates/linked_image_template.html2
-rw-r--r--templates/textfileform.html3
4 files changed, 14 insertions, 7 deletions
diff --git a/core/views/expo.py b/core/views/expo.py
index 79ad46a..5db2e37 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -501,9 +501,6 @@ def editexpopage(request, path):
print(f"Cookie set: {editor} for {COOKIE_MAX_AGE/(24*3600)} days")
try:
change_message = pageform.cleaned_data["change_message"]
- # 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})
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 9451d1e..d22bc89 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -15,7 +15,8 @@ from troggle.core.utils import (
COOKIE_MAX_AGE,
alphabet_suffix,
current_expo,
- get_cookie,
+ get_editor,
+ is_identified_user,
git_add,
git_commit,
git_string,
@@ -88,6 +89,7 @@ class ExpofileRenameForm(forms.Form): # not a model-form, just a form-form
class ExpotextfileForm(forms.Form): # not a model-form, just a form-form
"""Editing .txt files on /expoweb/ which is in a git repo"""
text = forms.CharField(strip=True, required=False)
+ identified_login = forms.BooleanField(required=False,widget=forms.CheckboxInput(attrs={"onclick":"return false"})) # makes it readonly
who_are_you = forms.CharField(
widget=forms.TextInput(
attrs={"size": 100, "placeholder": "You are editing this page, who are you ? e.g. 'Wookey' or 'Animal <mta@gasthof.expo>'",
@@ -103,7 +105,11 @@ def edittxtpage(request, path, filepath):
"""
def simple_get(viewtext):
print(f"simple_get {editor=}")
- form = ExpotextfileForm(initial={"who_are_you":editor})
+ form = ExpotextfileForm(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
+ form.fields["who_are_you"].widget.attrs["readonly"]="readonly"
+
return render(
request,
"textfileform.html",
@@ -131,7 +137,8 @@ def edittxtpage(request, path, filepath):
print(message)
return render(request, "errors/generic.html", {"message": message})
- editor = get_cookie(request)
+ identified_login = is_identified_user(request.user)
+ editor = get_editor(request)
if request.method == "GET":
return simple_get(originaltext)
diff --git a/templates/linked_image_template.html b/templates/linked_image_template.html
index 336f1dd..940782d 100644
--- a/templates/linked_image_template.html
+++ b/templates/linked_image_template.html
@@ -1 +1 @@
-<a href='{{ page_url }}'><img src='{{ thumbnail_url }}' /></a>
+<a href='{{ page_url }}'><img src='{{ thumbnail_url }}' /></a>&nbsp;
diff --git a/templates/textfileform.html b/templates/textfileform.html
index 75a5131..c2f7c11 100644
--- a/templates/textfileform.html
+++ b/templates/textfileform.html
@@ -30,7 +30,10 @@ Full path on server: {{filepath}}
<br /><br />
<div>
+<label for="id_identified_login">Identified login:</label>
+{{form.identified_login}}<br />
<label for="id_who_are_you">Who are you:</label><br />
+
{{form.who_are_you}}
</div><br />