Option to require an edit comment when saving a page.
I think it would be nice for a moinmoin administrator to easily require the wiki users add a comment about their edit.
An example implementation is available at ThemeMarket/FixedLeft#Edit_Log_Comments
-- JosephPrice
I had a patch for this feature lying around, so I'll share this here. The patch was created against 1.9.3, but it probably applies to 1.9.4 as well. There are really two patches: One to make the comment mandatory and one to show the editor again if the comment is left out (or on any other save error). The second patch works, but I don't think it's perfect yet. Review from someone who is a bit more familiar with the codebase would be welcome.
-- MatthijsKooijman Tue Apr 17 15:20:41 CEST 2012
1 Add a require_comment configuration directive.
2
3 This allows the comment to be made mandatory, with an appropriate save error
4 when no comment is filled in.
5 --- a/action/edit.py
6 +++ b/action/edit.py
7 @@ -161,6 +161,8 @@
8 from MoinMoin.security.textcha import TextCha
9 if not TextCha(request).check_answer_from_form():
10 raise pg.SaveError(_('TextCha: Wrong answer! Go back and try again...'))
11 + if request.cfg.require_comment and not comment:
12 + raise pg.SaveError(_('Supplying a comment is mandatory. Go back, write a comment and try again...'))
13 savemsg = pg.saveText(savetext, rev, trivial=trivial, comment=comment)
14 except pg.EditConflict, e:
15 msg = e.message
16 --- a/config/multiconfig.py
17 +++ b/config/multiconfig.py
18 @@ -954,6 +954,7 @@
19 ('edit_locking', 'warn 10', "Editor locking policy: `None`, `'warn <timeout in minutes>'`, or `'lock <timeout in minutes>'`"),
20 ('edit_ticketing', True, None),
21 ('edit_rows', 20, "Default height of the edit box"),
22 + ('require_comment', False, "if True, only allow saving when a comment is filled in"),
23
24 )),
25 # ==========================================================================
1 On a save error, show the editor again and mark the error.
2
3 Previously, the (unsaved) page would be shown again, with a small message with
4 class="info" at the top. It is easy to miss the save error like this,
5 especially since you get the page again instead of the editor. Also, browsers
6 might not always preserve your editor contents after pressing the back button.
7
8 With this patch, the error is clearly marked using the "error" message class.
9 Also, the editor is shown again, so you can fix the error right away.
10
11 Note: This patch does not yet seem to preserve the edited text on newly
12 created pages.
13 --- a/action/edit.py
14 +++ b/action/edit.py
15 @@ -162,7 +162,7 @@
16 if not TextCha(request).check_answer_from_form():
17 raise pg.SaveError(_('TextCha: Wrong answer! Go back and try again...'))
18 if request.cfg.require_comment and not comment:
19 - raise pg.SaveError(_('Supplying a comment is mandatory. Go back, write a comment and try again...'))
20 + raise pg.SaveError(_('Supplying a comment is mandatory. Write a comment below and try again...'))
21 savemsg = pg.saveText(savetext, rev, trivial=trivial, comment=comment)
22 except pg.EditConflict, e:
23 msg = e.message
24 @@ -176,8 +176,13 @@
25 return
26
27 except pg.SaveError, msg:
28 + # Make sure the new text is put into the editor again
29 + pg.set_raw_body(savetext, modified=1)
30 # msg contains a unicode string
31 - savemsg = unicode(msg)
32 + request.theme.add_msg(unicode(msg), "error")
33 + # Show the editor again
34 + pg.sendEditor(comment=comment)
35 + return
36
37 # Send new page after save or after unsuccessful conflict merge.
38 request.reset()
