summaryrefslogtreecommitdiffstats
path: root/core/views/uploads.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2025-02-17 22:31:10 +0200
committerPhilip Sargent <philip.sargent@gmail.com>2025-02-17 22:31:10 +0200
commit61c0f910884fd09166834d8776c03afbb1cd1e9a (patch)
tree80f0aca866a2855eeb9f51bf73fb6e8d383579c2 /core/views/uploads.py
parent6c30a9ffcb6005e32bd944dc1df3be4b7ed7a0da (diff)
downloadtroggle-61c0f910884fd09166834d8776c03afbb1cd1e9a.tar.gz
troggle-61c0f910884fd09166834d8776c03afbb1cd1e9a.tar.bz2
troggle-61c0f910884fd09166834d8776c03afbb1cd1e9a.zip
Drawing file upload now using identified_login (oops)
Diffstat (limited to 'core/views/uploads.py')
-rw-r--r--core/views/uploads.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 9f39276..d65a803 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -56,12 +56,13 @@ todo = """
class DrawingsFilesForm(forms.Form): # not a model-form, just a form-form
uploadfiles = forms.FileField()
- who_are_you = forms.CharField( # when this does not commit to git, this is not used.
+ 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>'",
+ attrs={"size": 100, "placeholder": "You are editing this page, who are you ? e.g. 'Becka' or 'Animal <mta@gasthof.expo>'",
"style": "vertical-align: text-top;"}
)
- )
+ )
class WalletFilesForm(forms.Form): # not a model-form, just a form-form
"""Used only for uploading to expofiles/surveyscans/<year>/<wallet>
@@ -568,11 +569,12 @@ def dwgupload(request, folder=None, gitdisable="no"):
You will find the Django documentation on forms very confusing, This is simpler.
We could validate the uploaded files as being a valid files using an XML parser, not a dubious script or hack,
- but this won't work on Tunnel files as Tunnel does not produce exactly valid xml
+ but this won't work on Tunnel files as Tunnel does not produce exactly valid xml (!)
We use get_or_create instead of simply creating a new object in case someone uploads the same file
- several times in one session, and expects them to be overwritten in the database. Although
- the actual file will be duplicated in the filesystem with different random name ending.
+ several times in one session, and expects them to be overwritten in the database. (Although
+ the actual file will be duplicated in the filesystem with different random name ending,
+ and this will need to be cleaned-up manually by a nerd later.)
"""
def dwgvalid(name):
@@ -622,8 +624,9 @@ def dwgupload(request, folder=None, gitdisable="no"):
urlfile = Path("/dwgdataraw/") / folder
urldir = Path("/dwgupload/") / folder
- editor = get_cookie(request)
- form = DrawingsFilesForm()
+ identified_login = is_identified_user(request.user)
+ editor = get_editor(request)
+ form = DrawingsFilesForm()
if request.method == "POST":
form = DrawingsFilesForm(request.POST, request.FILES)
@@ -727,12 +730,17 @@ def dwgupload(request, folder=None, gitdisable="no"):
if dirs:
dirs = sorted(dirs)
-
+
+ if identified_login:
+ # disable editing the git id string as we get it from the logged-on user data
+ print(f"IDENTIFIED {identified_login}")
+ form.fields["who_are_you"].widget.attrs["readonly"]="readonly"
response = render(
request,
- "dwguploadform.html",
+ "dwguploadform.html", # a bit more primitive than many forms in troggle, everything is very explicit and doesn't use widgets
{
"form": form,
+ "identified_login": identified_login,
"doesnotexist": doesnotexist,
"urlfile": urlfile,
"urldir": urldir,