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
--- 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):