mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-18 20:07:17 +00:00
Drawing file upload now using identified_login (oops)
This commit is contained in:
@@ -56,9 +56,10 @@ todo = """
|
|||||||
|
|
||||||
class DrawingsFilesForm(forms.Form): # not a model-form, just a form-form
|
class DrawingsFilesForm(forms.Form): # not a model-form, just a form-form
|
||||||
uploadfiles = forms.FileField()
|
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(
|
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;"}
|
"style": "vertical-align: text-top;"}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -568,11 +569,12 @@ def dwgupload(request, folder=None, gitdisable="no"):
|
|||||||
You will find the Django documentation on forms very confusing, This is simpler.
|
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,
|
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
|
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
|
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.
|
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):
|
def dwgvalid(name):
|
||||||
@@ -622,7 +624,8 @@ def dwgupload(request, folder=None, gitdisable="no"):
|
|||||||
urlfile = Path("/dwgdataraw/") / folder
|
urlfile = Path("/dwgdataraw/") / folder
|
||||||
urldir = Path("/dwgupload/") / folder
|
urldir = Path("/dwgupload/") / folder
|
||||||
|
|
||||||
editor = get_cookie(request)
|
identified_login = is_identified_user(request.user)
|
||||||
|
editor = get_editor(request)
|
||||||
form = DrawingsFilesForm()
|
form = DrawingsFilesForm()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
@@ -728,11 +731,16 @@ def dwgupload(request, folder=None, gitdisable="no"):
|
|||||||
if dirs:
|
if dirs:
|
||||||
dirs = sorted(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(
|
response = render(
|
||||||
request,
|
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,
|
"form": form,
|
||||||
|
"identified_login": identified_login,
|
||||||
"doesnotexist": doesnotexist,
|
"doesnotexist": doesnotexist,
|
||||||
"urlfile": urlfile,
|
"urlfile": urlfile,
|
||||||
"urldir": urldir,
|
"urldir": urldir,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<h3>All Tunnel and Therion files - linked to wallets, survey scans, frames and scraps</h3>
|
<h3>All Tunnel and Therion files - linked to wallets, survey scans, frames and scraps</h3>
|
||||||
<table style="font-size: 85%" width=95%>
|
<table style="font-size: 85%" width=95%>
|
||||||
<tr><th>File</th><th>Size</th><th>Paths</th><th>Wallets</th><th>Scan files in the wallets</th><th>Frames</th></tr>
|
<tr><th>Drawing (Tunnel or Therion) File</th><th>Size</th><th>Paths</th><th>Wallets</th><th>Scan files in the wallets</th><th>Frames</th></tr>
|
||||||
|
|
||||||
{% for dwgfile in dwgfiles %}
|
{% for dwgfile in dwgfiles %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -10,13 +10,22 @@
|
|||||||
<form method ='post' enctype ="multipart/form-data">
|
<form method ='post' enctype ="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<br /><br /> <br /><br />
|
<br /><br /> <br /><br />
|
||||||
<label for="who_are_you">Who are you, uploading these files?</label>
|
<div style= "text-align: left;">
|
||||||
|
Identified login
|
||||||
|
<input type="checkbox" name="identified_login" onclick="return false" id="id_identified_login"
|
||||||
|
{% if identified_login %} checked{% endif %} ">
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<input {% if not user.username %} disabled{% endif %}
|
|
||||||
|
<label for="who_are_you">Who are you, uploading these files?</label>
|
||||||
|
<br />
|
||||||
|
<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/>
|
||||||
<br /><br /> <br>
|
<br /><br /> <br />
|
||||||
|
</div>
|
||||||
<input class="fancybutton" type = "file" multiple="multiple"
|
<input class="fancybutton" type = "file" multiple="multiple"
|
||||||
name = "uploadfiles" id="uploadfiles" />
|
name = "uploadfiles" id="uploadfiles" />
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
@@ -26,7 +35,8 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div style = "max-width:70%; margin-left:20%; text-align: left" >
|
<div style = "max-width:70%; margin-left:20%; text-align: left" >
|
||||||
<p>Only drawings and drawing config files can be uploaded.
|
<p>Only drawings and drawing config files can be uploaded.<br />
|
||||||
|
topo and other digital instrument survey files should be uploaded to a Wallet, e.g. <a href="/wallets/year/2025">2025</a>.
|
||||||
</div>
|
</div>
|
||||||
<div style = "max-width:70%; margin-left:20%; text-align: left" >
|
<div style = "max-width:70%; margin-left:20%; text-align: left" >
|
||||||
{% if refused %}
|
{% if refused %}
|
||||||
|
|||||||
Reference in New Issue
Block a user