2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 23:47:04 +00:00

final final final: logbook edit form (humph)

This commit is contained in:
2025-02-17 23:01:56 +02:00
parent c23e93d7a7
commit 95190324fb
2 changed files with 18 additions and 6 deletions

View File

@@ -17,7 +17,8 @@ from troggle.core.utils import (
add_commit, add_commit,
alphabet_suffix, alphabet_suffix,
current_expo, current_expo,
get_cookie, get_editor,
is_identified_user,
git_string, git_string,
sanitize_name, sanitize_name,
unique_slug, unique_slug,
@@ -162,7 +163,8 @@ def logbookedit(request, year=None, slug=None):
"form": form, "form": form,
"year": year, "year": year,
"yesterday": yesterday(), "yesterday": yesterday(),
"identified_login": identified_login,
"who_are_you": editor,
}, },
) )
def clean_tu(tu): def clean_tu(tu):
@@ -186,8 +188,8 @@ def logbookedit(request, year=None, slug=None):
year = current_expo() year = current_expo()
author = "" author = ""
editor = get_cookie(request) identified_login = is_identified_user(request.user)
editor = get_editor(request)
if request.method == "POST": if request.method == "POST":
prev_slug = "" # None value pending overwrite from submitted form prev_slug = "" # None value pending overwrite from submitted form
@@ -391,6 +393,7 @@ def logbookedit(request, year=None, slug=None):
text = lbe.text text = lbe.text
rows = max(5,len(text)/50) rows = max(5,len(text)/50)
print("IDENT",identified_login, who_are_you)
return render( return render(
request, request,
"logbookform.html", "logbookform.html",
@@ -407,12 +410,14 @@ def logbookedit(request, year=None, slug=None):
"entry": text, "entry": text,
"textrows": rows, "textrows": rows,
"slug": slug, "slug": slug,
"identified_login": identified_login,
"who_are_you": editor, "who_are_you": editor,
}, },
) )
class LogbookEditForm(forms.Form): # not a model-form, just a form-form class LogbookEditForm(forms.Form): # not a model-form, just a form-form
author = forms.CharField(strip=True, required=False) author = 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( who_are_you = forms.CharField(
widget=forms.TextInput( # a manual form, not a Django generated form, so this widget is not used. widget=forms.TextInput( # a manual form, not a Django generated form, so this widget is not used.
attrs={"size": 100, "placeholder": "You are editing this page, who are you ? e.g. 'Wookey' or 'Animal <mta@gasthof.expo>'", attrs={"size": 100, "placeholder": "You are editing this page, who are you ? e.g. 'Wookey' or 'Animal <mta@gasthof.expo>'",

View File

@@ -93,8 +93,15 @@
{% if tu %}value="{{tu}}"{% else %}placeholder="0.1" {% endif %} {% if tu %}value="{{tu}}"{% else %}placeholder="0.1" {% endif %}
/> />
<br /><br /> <br /><br />
<label for="who_are_you">Who are you, editing this logbook entry?</label> Identified login
<input {% if not user.username %} disabled{% endif %} <input type="checkbox" name="identified_login" onclick="return false" id="id_identified_login"
{% if identified_login %} checked{% endif %} ">
<br /><br />
<label for="who_are_you">Who are you, editing this logbook entry?</label>
<input
{% if not user.username %} disabled{% endif %}
{% if identified_login %} readonly{% endif %}
label = "Who are you" name = "who_are_you" size ="70" label = "Who are you" name = "who_are_you" size ="70"
title="Who are you" title="Who are you"
placeholder="editor's name for version control e.g. 'Animal <mta@gasthof.expo>'" value="{{who_are_you}}" required/> placeholder="editor's name for version control e.g. 'Animal <mta@gasthof.expo>'" value="{{who_are_you}}" required/>