Fix wrong redirect when changing partial path or link name. Remove an unnecessary assignment in logic/models/base.py that would generate an error when an entity did not exist.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Tue, 04 Nov 2008 20:06:36 +0000
changeset 442 92c17629af0e
parent 441 8a7110ad3d82
child 443 94568ac6e3e1
Fix wrong redirect when changing partial path or link name. Remove an unnecessary assignment in logic/models/base.py that would generate an error when an entity did not exist. Patch by: Lennard de Rijk Review by: Pawel Solyga
app/soc/logic/models/base.py
app/soc/views/models/base.py
--- a/app/soc/logic/models/base.py	Tue Nov 04 14:09:37 2008 +0000
+++ b/app/soc/logic/models/base.py	Tue Nov 04 20:06:36 2008 +0000
@@ -190,8 +190,6 @@
       # an entity exist for this link_name, so return that entity
       return entity
 
-    fields = []
-
     format_text = ugettext_lazy('"%(key)s" is "%(value)s"')
 
     msg_pairs = [format_text % {'key': key, 'value': value}
--- a/app/soc/views/models/base.py	Tue Nov 04 14:09:37 2008 +0000
+++ b/app/soc/views/models/base.py	Tue Nov 04 20:06:36 2008 +0000
@@ -191,6 +191,9 @@
 
     fields = self.collectCleanedFields(form)
 
+    # get the old_suffix before editing
+    old_suffix = self._logic.getKeySuffix(entity)
+
     self._editPost(request, entity, fields)
 
     key_fields = self._logic.getKeyFieldsFromDict(fields)
@@ -205,7 +208,7 @@
     # redirect to (possibly new) location of the entity
     # (causes 'Profile saved' message to be displayed)
     return helper.responses.redirectToChangedSuffix(
-        request, suffix, suffix,
+        request, old_suffix, suffix,
         params=params)
 
   def editGet(self, request, entity, context):