mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 13:07:11 +00:00
text file editor now using validated logon properly
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
<a href='{{ page_url }}'><img src='{{ thumbnail_url }}' /></a>
|
||||
<a href='{{ page_url }}'><img src='{{ thumbnail_url }}' /></a>
|
||||
|
||||
@@ -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 />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user