mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-18 08:27:13 +00:00
rename Forms to be more understandable
This commit is contained in:
@@ -53,28 +53,40 @@ todo = """
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class FilesForm(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(
|
who_are_you = forms.CharField( # when this does not commit to git, this is not used.
|
||||||
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. 'Wookey' or 'Animal <mta@gasthof.expo>'",
|
||||||
"style": "vertical-align: text-top;"}
|
"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>
|
||||||
|
which is not a git repo so we do not need an "editor" to assign blame to
|
||||||
|
"""
|
||||||
|
uploadfiles = forms.FileField()
|
||||||
|
|
||||||
|
|
||||||
|
class PhotographerForm(forms.Form): # not a model-form, just a form-form
|
||||||
|
photographer = forms.CharField(strip=True)
|
||||||
|
|
||||||
|
class GPXuploadForm(forms.Form): # not a model-form, just a form-form
|
||||||
|
prospector = forms.CharField(strip=True)
|
||||||
|
|
||||||
class FilesRenameForm(forms.Form): # not a model-form, just a form-form
|
class FilesRenameForm(forms.Form): # not a model-form, just a form-form
|
||||||
|
"""Used only for renaming photos in /expofiles/photos/
|
||||||
|
which is not a git repo
|
||||||
|
"""
|
||||||
uploadfiles = forms.FileField()
|
uploadfiles = forms.FileField()
|
||||||
renameto = forms.CharField(strip=True, required=False)
|
renameto = forms.CharField(strip=True, required=False)
|
||||||
|
|
||||||
class TextForm(forms.Form): # not a model-form, just a form-form
|
|
||||||
photographer = forms.CharField(strip=True)
|
|
||||||
|
|
||||||
class TextProspectorForm(forms.Form): # not a model-form, just a form-form
|
|
||||||
prospector = forms.CharField(strip=True)
|
|
||||||
|
|
||||||
class ExpofileRenameForm(forms.Form): # not a model-form, just a form-form
|
class ExpofileRenameForm(forms.Form): # not a model-form, just a form-form
|
||||||
renameto = forms.CharField(strip=True, required=False)
|
renameto = forms.CharField(strip=True, required=False)
|
||||||
|
|
||||||
class ExpotextfileForm(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)
|
text = forms.CharField(strip=True, required=False)
|
||||||
who_are_you = forms.CharField(
|
who_are_you = forms.CharField(
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
@@ -391,12 +403,12 @@ def photoupload(request, folder=None):
|
|||||||
urldir = f"/photoupload/{year}"
|
urldir = f"/photoupload/{year}"
|
||||||
|
|
||||||
form = FilesRenameForm()
|
form = FilesRenameForm()
|
||||||
formd = TextForm()
|
formd = PhotographerForm()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if "photographer" in request.POST:
|
if "photographer" in request.POST:
|
||||||
# then we are creating a new folder
|
# then we are creating a new folder
|
||||||
formd = TextForm(request.POST)
|
formd = PhotographerForm(request.POST)
|
||||||
if formd.is_valid():
|
if formd.is_valid():
|
||||||
newphotographer = sanitize_name(request.POST["photographer"])
|
newphotographer = sanitize_name(request.POST["photographer"])
|
||||||
try:
|
try:
|
||||||
@@ -526,7 +538,7 @@ def gpxupload(request, folder=None):
|
|||||||
|
|
||||||
print(f"gpxupload() {folder=} {dirpath=} {urlfile=} {urldir=}")
|
print(f"gpxupload() {folder=} {dirpath=} {urlfile=} {urldir=}")
|
||||||
form = FilesRenameForm()
|
form = FilesRenameForm()
|
||||||
formd = TextProspectorForm()
|
formd = GPXuploadForm()
|
||||||
print(f"gpxupload() {form=} {formd=} ")
|
print(f"gpxupload() {form=} {formd=} ")
|
||||||
|
|
||||||
|
|
||||||
@@ -537,7 +549,7 @@ def gpxupload(request, folder=None):
|
|||||||
|
|
||||||
if "prospector" in request.POST:
|
if "prospector" in request.POST:
|
||||||
print(f"gpxupload() {request.POST=}\n {request.POST['prospector']=}")
|
print(f"gpxupload() {request.POST=}\n {request.POST['prospector']=}")
|
||||||
formd = TextProspectorForm(request.POST)
|
formd = GPXuploadForm(request.POST)
|
||||||
if formd.is_valid():
|
if formd.is_valid():
|
||||||
newprospector = sanitize_name(request.POST["prospector"])
|
newprospector = sanitize_name(request.POST["prospector"])
|
||||||
print(f"gpxupload() {newprospector=}")
|
print(f"gpxupload() {newprospector=}")
|
||||||
@@ -711,10 +723,10 @@ def dwgupload(request, folder=None, gitdisable="no"):
|
|||||||
urldir = Path("/dwgupload/") / folder
|
urldir = Path("/dwgupload/") / folder
|
||||||
|
|
||||||
editor = get_cookie(request)
|
editor = get_cookie(request)
|
||||||
form = FilesForm()
|
form = DrawingsFilesForm()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = FilesForm(request.POST, request.FILES)
|
form = DrawingsFilesForm(request.POST, request.FILES)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
# print(f'! - FORM dwgupload - POST valid: "{request.FILES["uploadfiles"]}" ')
|
# print(f'! - FORM dwgupload - POST valid: "{request.FILES["uploadfiles"]}" ')
|
||||||
editor = form.cleaned_data["who_are_you"]
|
editor = form.cleaned_data["who_are_you"]
|
||||||
|
|||||||
Reference in New Issue
Block a user