link to created entity when redirected to another page stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 30 Jun 2009 08:05:57 +0200
branchstable
changeset 2202 cb374512949f
parent 2201 ddc1f58c8e8b
child 2203 efdd3a9f9028
link to created entity when redirected to another page
web/controller.py
web/request.py
--- a/web/controller.py	Tue Jun 30 08:05:18 2009 +0200
+++ b/web/controller.py	Tue Jun 30 08:05:57 2009 +0200
@@ -182,6 +182,12 @@
         elif '__redirectpath' in self.req.form:
             # if redirect path was explicitly specified in the form, use it
             path = self.req.form['__redirectpath']
+            if self._edited_entity:
+                msg = newparams.get('__message', '')
+                msg += ' (<a href="%s">%s</a>)' % (
+                    self._edited_entity.absolute_url(),
+                    self.req._('click here to see created entity'))
+                newparams['__createdpath'] = self._edited_entity.rest_path()
         elif self._after_deletion_path:
             # else it should have been set during form processing
             path, params = self._after_deletion_path
--- a/web/request.py	Tue Jun 30 08:05:18 2009 +0200
+++ b/web/request.py	Tue Jun 30 08:05:57 2009 +0200
@@ -150,6 +150,11 @@
                 del self.form[k]
             else:
                 self.form[k] = v
+        # special key for created entity, added in controller's reset method
+        if '__createdpath' in params:
+            self.message += ' (<a href="%s">%s</a>)' % (
+                self.build_url(params.pop('__createdpath')),
+                self._('click here to see created entity'))
 
     def no_script_form_param(self, param, default=None, value=None):
         """ensure there is no script in a user form param