2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 05:27:12 +00:00

text file editor now using validated logon properly

This commit is contained in:
2025-02-13 16:42:51 +00:00
parent 3fb99eb4be
commit a976497b3a
4 changed files with 14 additions and 7 deletions

View File

@@ -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)