forked from expo/troggle
Add git commit messages when editing via website. Make sure cust menus are not deleted.
This commit is contained in:
@@ -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)"}))
|
||||
|
||||
Reference in New Issue
Block a user