changeset 5890:6d5105a45257

on a save error, show the editor again and highlight the error as such Previously, the (unsaved) page would be shown again, with a small message with class="info" at the top. It is easy to miss the save error like this, especially since you get the page again instead of the editor. Also, browsers might not always preserve your editor contents after pressing the back button. With this patch, the error is clearly marked using the "error" message class. Also, the editor is shown again (just as if the user clicked preview), so you can fix the error right away.
author Matthijs Kooijman <matthijs@stdin.nl>
date Thu, 20 Sep 2012 17:47:04 +0200
parents e2754e834244
children 16f3285443ca
files MoinMoin/action/edit.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/edit.py	Thu Sep 20 17:45:31 2012 +0200
+++ b/MoinMoin/action/edit.py	Thu Sep 20 17:47:04 2012 +0200
@@ -160,9 +160,9 @@
         try:
             from MoinMoin.security.textcha import TextCha
             if not TextCha(request).check_answer_from_form():
-                raise pg.SaveError(_('TextCha: Wrong answer! Go back and try again...'))
+                raise pg.SaveError(_('TextCha: Wrong answer! Try again below...'))
             if request.cfg.require_comment and not comment:
-                raise pg.SaveError(_('Supplying a comment is mandatory. Go back, write a comment and try again...'))
+                raise pg.SaveError(_('Supplying a comment is mandatory.  Write a comment below and try again...'))
             savemsg = pg.saveText(savetext, rev, trivial=trivial, comment=comment)
         except pg.EditConflict, e:
             msg = e.message
@@ -176,10 +176,13 @@
             return
 
         except pg.SaveError, msg:
-            # msg contains a unicode string
-            savemsg = unicode(msg)
+            # Show the error message
+            request.theme.add_msg(unicode(msg), "error")
+            # And show the editor again
+            pg.sendEditor(preview=savetext, comment=comment, staytop=1)
+            return
 
-        # Send new page after save or after unsuccessful conflict merge.
+        # Send new page after successful save
         request.reset()
         pg = Page(request, pagename)