2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 21:57:08 +00:00

error handling for txt editor

This commit is contained in:
2024-07-03 12:34:21 +03:00
parent cb81a066db
commit b6ffcb63bf
2 changed files with 32 additions and 1 deletions

View File

@@ -155,6 +155,7 @@ class LogbookEditForm(forms.Form): # not a model-form, just a form-form
def edittxtpage(request, path, filepath):
"""Editing a .txt file on expoweb/
"""
message=""
def simple_get():
form = ExpotextfileForm()
return render(
@@ -163,6 +164,7 @@ def edittxtpage(request, path, filepath):
{
"form": form,
"path": path,
"message": message,
"filepath": filepath,
"text": text,
},
@@ -183,7 +185,29 @@ def edittxtpage(request, path, filepath):
return simple_get()
elif request.method == "POST":
pass
form = ExpotextfileForm(request.POST)
if not form.is_valid():
message = f'Invalid form response for text file editing "{request.POST}"'
print(message)
return render(request, "errors/generic.html", {"message": message})
else:
for i in request.POST:
print(":: ",i, " => ", request.POST[i])
print("POST")
if "Cancel" in request.POST:
print("cancel")
return simple_get()
if "Save" in request.POST:
print("submitted for saving..")
message="submitted for saving.. not implemented yet.."
# INSERT FILE SAVING AND git committing on server
return simple_get()
# mistake, abort
message="Something went wrong"
return simple_get()
@login_required_if_public
def logbookedit(request, year=None, slug=None):