summaryrefslogtreecommitdiffstats
path: root/core/views/expo.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/views/expo.py')
-rw-r--r--core/views/expo.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/views/expo.py b/core/views/expo.py
index a151a4d..5fa3b33 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -451,11 +451,14 @@ def editexpopage(request, path):
print("### File not found ### ", filepath)
filefound = False
+ editor_name = request.COOKIES.get('editor_id', '') # if no cookie, then get empty string
+
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
# print("### \n", str(pageform)[0:300])
# print("### \n csrfmiddlewaretoken: ",request.POST['csrfmiddlewaretoken'])
+ if not editor_name:
if filefound:
headmatch = re.match(r"(.*)<title>.*</title>(.*)", head, re.DOTALL + re.IGNORECASE)
if headmatch:
@@ -476,7 +479,7 @@ def editexpopage(request, path):
bodyargs = ""
postbody = "</html>\n"
body = pageform.cleaned_data["html"]
- body = body.replace("\r", "\n")
+ body = body.replace("\r", "")
result = f"{preheader}<head{headerargs}>{head}</head>{postheader}<body{bodyargs}>\n{body}</body>{postbody}"
if not filefound or result != html: # Check if content changed at all
@@ -495,9 +498,11 @@ def editexpopage(request, path):
(title,) = m.groups()
else:
title = ""
- pageform = ExpoPageForm(initial={"html": body, "title": title})
+ pageform = ExpoPageForm(initial={"who_are_you":editor_name, "html": body, "title": title})
else:
- pageform = ExpoPageForm()
+ pageform = ExpoPageForm(initial={"who_are_you":editor_name})
+
+
return render(
request,
"editexpopage.html",
@@ -528,7 +533,7 @@ class ExpoPageForm(forms.Form):
)
who_are_you = forms.CharField(
widget=forms.Textarea(
- attrs={"cols": 90, "rows": 1, "placeholder": "You have edited this page, who are you ? e.g. 'Animal <mta@loveshack.expo>'",
+ attrs={"cols": 90, "rows": 1, "placeholder": "You have edited this page, who are you ? e.g. 'Animal <mta@gasthof.expo>'",
"style": "vertical-align: text-top;"}
),
label = "Editor"