equal
deleted
inserted
replaced
195 empty_kwargs = {} |
195 empty_kwargs = {} |
196 fields = self._logic.getKeyFieldNames() |
196 fields = self._logic.getKeyFieldNames() |
197 for field in fields: |
197 for field in fields: |
198 empty_kwargs[field] = None |
198 empty_kwargs[field] = None |
199 |
199 |
200 request.path = params['create_redirect'] |
|
201 request.path = helper.requests.replaceSuffix(request.path, |
|
202 old_suffix='edit', |
|
203 new_suffix='edit') |
|
204 |
|
205 if not kwargs: |
200 if not kwargs: |
206 return self.edit(request, page_name=page_name, params=params, |
201 return self.edit(request, page_name=page_name, params=params, |
207 **empty_kwargs) |
202 **empty_kwargs) |
208 else: |
203 else: |
209 return self.edit(request, page_name=page_name, params=params, |
204 return self.edit(request, page_name=page_name, params=params, |
264 return self._constructResponse(request, entity, context, form, params) |
259 return self._constructResponse(request, entity, context, form, params) |
265 |
260 |
266 key_name, fields = self.collectCleanedFields(form) |
261 key_name, fields = self.collectCleanedFields(form) |
267 |
262 |
268 # get the old_suffix before editing |
263 # get the old_suffix before editing |
269 old_suffix = self._logic.getKeySuffix(entity) |
264 if entity: |
|
265 old_suffix = '%s%s' %('edit/', self._logic.getKeySuffix(entity)) |
|
266 else: |
|
267 # retrieve the suffix appened to the create path |
|
268 splitted_path = request.path.split('/create/',1) |
|
269 if len(splitted_path) == 2 : |
|
270 old_suffix = '%s%s' %('create/', splitted_path[1]) |
|
271 else: |
|
272 # no suffix after the create in the request path |
|
273 old_suffix = 'create' |
270 |
274 |
271 self._editPost(request, entity, fields) |
275 self._editPost(request, entity, fields) |
272 |
276 |
273 if not key_name: |
277 if not key_name: |
274 key_fields = self._logic.getKeyFieldsFromDict(fields) |
278 key_fields = self._logic.getKeyFieldsFromDict(fields) |
278 |
282 |
279 if not entity: |
283 if not entity: |
280 return http.HttpResponseRedirect('/') |
284 return http.HttpResponseRedirect('/') |
281 |
285 |
282 page_params = params['edit_params'] |
286 page_params = params['edit_params'] |
283 suffix = self._logic.getKeySuffix(entity) |
287 new_suffix = '%s%s' %('edit/', self._logic.getKeySuffix(entity)) |
284 |
288 |
285 # redirect to (possibly new) location of the entity |
289 # redirect to (possibly new) location of the entity |
286 # (causes 'Profile saved' message to be displayed) |
290 # (causes 'Profile saved' message to be displayed) |
287 return helper.responses.redirectToChangedSuffix( |
291 return helper.responses.redirectToChangedSuffix( |
288 request, old_suffix, suffix, |
292 request, old_suffix, new_suffix, |
289 params=page_params) |
293 params=page_params) |
290 |
294 |
291 def editGet(self, request, entity, context, seed, params): |
295 def editGet(self, request, entity, context, seed, params): |
292 """Same as edit, but on GET. |
296 """Same as edit, but on GET. |
293 """ |
297 """ |