summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/views/expo.py3
-rw-r--r--core/views/uploads.py13
2 files changed, 10 insertions, 6 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)