2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-18 20:27:08 +00:00

initial text file editing stuff

This commit is contained in:
2024-07-03 11:48:38 +03:00
parent 704ff8335d
commit cb81a066db
4 changed files with 94 additions and 3 deletions

View File

@@ -146,9 +146,45 @@ class TextForm(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)
class ExpotextfileForm(forms.Form): # not a model-form, just a form-form
text = forms.CharField(strip=True, required=False)
class LogbookEditForm(forms.Form): # not a model-form, just a form-form
author = forms.CharField(strip=True, required=False)
def edittxtpage(request, path, filepath):
"""Editing a .txt file on expoweb/
"""
def simple_get():
form = ExpotextfileForm()
return render(
request,
"textfileform.html",
{
"form": form,
"path": path,
"filepath": filepath,
"text": text,
},
)
if not filepath.is_file():
print(f"Not a file: {filepath}")
errpage = f"<html>" + default_head + f"<h3>File not found '{filepath}'<br><br>failure detected in expowebpage() in views.expo.py</h3> </body>"
return HttpResponse(errpage)
try:
with open(filepath) as f:
text = f.read()
except IOError:
print("### File reading failue, but it exists.. ### ", filepath)
filefound = False
if request.method == "GET":
return simple_get()
elif request.method == "POST":
pass
@login_required_if_public
def logbookedit(request, year=None, slug=None):
"""Edit a logbook entry