[controller] UndoController: fix output method (closes: #1776091) stable
authorJulien Jehannet <julien.jehannet@logilab.fr>
Thu, 23 Jun 2011 10:24:40 +0200
branchstable
changeset 7557 a397305f3976
parent 7556 867ec36530b8
child 7558 044135305359
[controller] UndoController: fix output method (closes: #1776091) Fix buggy direct output in `UndoController.publish()`. Raise now a ValidationError instead of malformed string Changes: * raise ValidationError when an error occured in undo * use the new message mechanism based on _cwmsgid If errors are not fatal, you have to change publish() method.
i18n/fr.po
web/views/basecontrollers.py
--- a/i18n/fr.po	Fri Jun 24 14:10:37 2011 +0200
+++ b/i18n/fr.po	Thu Jun 23 10:24:40 2011 +0200
@@ -4,7 +4,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: cubicweb 2.46.0\n"
-"PO-Revision-Date: 2011-01-03 14:35+0100\n"
+"PO-Revision-Date: 2011-06-23 10:23+0200\n"
 "Last-Translator: Logilab Team <contact@logilab.fr>\n"
 "Language-Team: fr <contact@logilab.fr>\n"
 "Language: \n"
@@ -4077,7 +4077,7 @@
 msgstr "n° de transition"
 
 msgid "transaction undone"
-msgstr "transaction annulées"
+msgstr "transaction annulée"
 
 #, python-format
 msgid "transition %(tr)s isn't allowed from %(st)s"
--- a/web/views/basecontrollers.py	Fri Jun 24 14:10:37 2011 +0200
+++ b/web/views/basecontrollers.py	Thu Jun 23 10:24:40 2011 +0200
@@ -603,16 +603,14 @@
         errors = self._cw.cnx.undo_transaction(txuuid)
         if not errors:
             self.redirect()
-        return self._cw._('some errors occurred:') + self._cw.view(
-            'pyvallist', pyvalue=errors)
+        raise ValidationError(None, {None: '\n'.join(errors)})
 
-    def redirect(self):
+    def redirect(self, msg=None):
         req = self._cw
+        msg = msg or req._("transaction undone")
         breadcrumbs = req.session.data.get('breadcrumbs', None)
         if breadcrumbs is not None and len(breadcrumbs) > 1:
-            url = req.rebuild_url(breadcrumbs[-2],
-                                  __message=req._('transaction undoed'))
+            url = req.rebuild_url(breadcrumbs[-2], __message=msg)
         else:
-            url = req.build_url(__message=req._('transaction undoed'))
+            url = req.build_url(__message=msg)
         raise Redirect(url)
-