2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 00:07:09 +00:00

Add git commit messages when editing via website. Make sure cust menus are not deleted.

This commit is contained in:
Martin Green
2022-06-23 21:31:57 +01:00
parent 97a9f2aae6
commit ef68db080a
2 changed files with 13 additions and 22 deletions

View File

@@ -341,7 +341,8 @@ def editexpopage(request, path):
if result != html: # Check if content changed
try:
version_control.write_and_commit(filepath, result)
change_message = pageform.cleaned_data["change_message"]
version_control.write_and_commit(filepath, result, f'{change_message} - online edit of {path}')
except version_control.WriteAndCommitError as e:
return render(request,'errors/generic.html', {'message': e.message})
@@ -353,20 +354,14 @@ def editexpopage(request, path):
title, = m.groups()
else:
title = ""
pageform = ExpoPageForm({"html": body, "title": title})
pageform = ExpoPageForm(initial = {"html": body, "title": title})
else:
body = "### File not found ###\n" + str(filepath)
import sys
import locale
body = body + "\nsys.getdefaultencoding() = " + str(sys.getdefaultencoding())
body = body + "\nsys.getfilesystemencoding() = " + str(sys.getfilesystemencoding())
body = body + "\nlocale.getdefaultlocale() = " + str(locale.getdefaultlocale())
body = body + "\nlocale.getpreferredencoding() = " + str(locale.getpreferredencoding())
pageform = ExpoPageForm({"html": body, "title": "Missing"})
pageform = ExpoPageForm()
return render(request, 'editexpopage.html', {'path': path, 'form': pageform, })
class ExpoPageForm(forms.Form):
'''The form used by the editexpopage function
'''
title = forms.CharField(widget=forms.TextInput(attrs={'size':'60'}))
html = forms.CharField(widget=forms.Textarea(attrs={"cols":80, "rows":20}))
title = forms.CharField(widget=forms.TextInput(attrs={'size':'60', 'placeholder': "Enter title (displayed in tab)"}))
html = forms.CharField(widget=forms.Textarea(attrs={"cols":80, "rows":20, 'placeholder': "Enter page content (using HTML)"}))
change_message = forms.CharField(widget=forms.Textarea(attrs={"cols":80, "rows":5, 'placeholder': "Descibe the change made (for git)"}))