mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
error handling for txt editor
This commit is contained in:
parent
cb81a066db
commit
b6ffcb63bf
@ -155,6 +155,7 @@ class LogbookEditForm(forms.Form): # not a model-form, just a form-form
|
|||||||
def edittxtpage(request, path, filepath):
|
def edittxtpage(request, path, filepath):
|
||||||
"""Editing a .txt file on expoweb/
|
"""Editing a .txt file on expoweb/
|
||||||
"""
|
"""
|
||||||
|
message=""
|
||||||
def simple_get():
|
def simple_get():
|
||||||
form = ExpotextfileForm()
|
form = ExpotextfileForm()
|
||||||
return render(
|
return render(
|
||||||
@ -163,6 +164,7 @@ def edittxtpage(request, path, filepath):
|
|||||||
{
|
{
|
||||||
"form": form,
|
"form": form,
|
||||||
"path": path,
|
"path": path,
|
||||||
|
"message": message,
|
||||||
"filepath": filepath,
|
"filepath": filepath,
|
||||||
"text": text,
|
"text": text,
|
||||||
},
|
},
|
||||||
@ -183,7 +185,29 @@ def edittxtpage(request, path, filepath):
|
|||||||
return simple_get()
|
return simple_get()
|
||||||
|
|
||||||
elif request.method == "POST":
|
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
|
@login_required_if_public
|
||||||
def logbookedit(request, year=None, slug=None):
|
def logbookedit(request, year=None, slug=None):
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
<div style = "max-width:95%; margin-left:4%; font-family: monospace; font-weight: bold; font-size: 110%; text-align: left; " >
|
<div style = "max-width:95%; margin-left:4%; font-family: monospace; font-weight: bold; font-size: 110%; text-align: left; " >
|
||||||
File: {{path}} <br>
|
File: {{path}} <br>
|
||||||
Full path on server: {{filepath}}
|
Full path on server: {{filepath}}
|
||||||
|
{% if message %}
|
||||||
|
<p style="color:red">{{message}}</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<form method ='post' >
|
<form method ='post' >
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
@ -30,6 +33,10 @@ Full path on server: {{filepath}}
|
|||||||
title="Saves the file in UTF-8 characterset" value = "Save" >
|
title="Saves the file in UTF-8 characterset" value = "Save" >
|
||||||
Save the file
|
Save the file
|
||||||
</button>
|
</button>
|
||||||
|
<button class="fancybutton2" style="padding: 0.5em 25px; margin-left: 110px" name="Cancel" type = "submit"
|
||||||
|
title="Aborts the editing" value = "Cancel" >
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user