diff options
author | Martin Green <martin.speleo@gmail.com> | 2022-06-23 21:31:57 +0100 |
---|---|---|
committer | Martin Green <martin.speleo@gmail.com> | 2022-06-23 21:31:57 +0100 |
commit | ef68db080a5a4af746881c8227b0456d1626f076 (patch) | |
tree | 617ad48f2d2764f2523a5f6479817b4ccf4e561a /core/views/expo.py | |
parent | 97a9f2aae6b09bbf901f5e17e66d01a89d6d81ed (diff) | |
download | troggle-ef68db080a5a4af746881c8227b0456d1626f076.tar.gz troggle-ef68db080a5a4af746881c8227b0456d1626f076.tar.bz2 troggle-ef68db080a5a4af746881c8227b0456d1626f076.zip |
Add git commit messages when editing via website. Make sure cust menus are not deleted.
Diffstat (limited to 'core/views/expo.py')
-rw-r--r-- | core/views/expo.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/core/views/expo.py b/core/views/expo.py index cc1b543..0168a07 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -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)"})) |