app/soc/views/models/base.py
changeset 403 d3e545a8bd26
parent 402 021e86368600
child 407 3cf5630d86d1
equal deleted inserted replaced
402:021e86368600 403:d3e545a8bd26
   191 
   191 
   192     if not entity:
   192     if not entity:
   193       return http.HttpResponseRedirect('/')
   193       return http.HttpResponseRedirect('/')
   194 
   194 
   195     params = self._params['edit_params']
   195     params = self._params['edit_params']
   196     suffix = self._logic.constructKeyNameSuffix(fields)
   196     suffix = self._logic.constructKeyNameSuffix(entity)
   197 
   197 
   198     # redirect to (possibly new) location of the entity
   198     # redirect to (possibly new) location of the entity
   199     # (causes 'Profile saved' message to be displayed)
   199     # (causes 'Profile saved' message to be displayed)
   200     return helper.responses.redirectToChangedSuffix(
   200     return helper.responses.redirectToChangedSuffix(
   201         request, suffix, suffix,
   201         request, suffix, suffix,
   202         params=params)
   202         params=params)
   203 
   203 
   204   def editGet(self, request, entity, context):
   204   def editGet(self, request, entity, context):
   205     """Same as edit, but on GET
   205     """Same as edit, but on GET
   206     """
   206     """
   207     # TODO(SRabbelier): Construct a suffix
   207 
   208     suffix = None    
   208     suffix = self._logic.constructKeyNameSuffix(entity)
   209 
   209 
   210     # Remove the params from the request, this is relevant only if
   210     # Remove the params from the request, this is relevant only if
   211     # someone bookmarked a POST page.
   211     # someone bookmarked a POST page.
   212     is_self_referrer = helper.requests.isReferrerSelf(request, suffix=suffix)
   212     is_self_referrer = helper.requests.isReferrerSelf(request, suffix=suffix)
   213     if request.GET.get(self.DEF_SUBMIT_MSG_PARAM_NAME):
   213     if request.GET.get(self.DEF_SUBMIT_MSG_PARAM_NAME):
   350       entity: the entity that is used
   350       entity: the entity that is used
   351       context: the context to be used
   351       context: the context to be used
   352       form: the form that will be used
   352       form: the form that will be used
   353     """
   353     """
   354 
   354 
       
   355     if entity:
       
   356       suffix = self._logic.constructKeyNameSuffix(entity)
       
   357     else:
       
   358       suffix = None
       
   359 
   355     context['form'] = form
   360     context['form'] = form
   356     context['entity'] = entity
   361     context['entity'] = entity
       
   362     context['entity_suffix'] = suffix
   357     context['entity_type'] = self._params['name']
   363     context['entity_type'] = self._params['name']
   358     context['entity_type_plural'] = self._params['name_plural']
   364     context['entity_type_plural'] = self._params['name_plural']
       
   365     context['entity_type_short'] = self._params['name_short']
   359 
   366 
   360     template = self._params['edit_template']
   367     template = self._params['edit_template']
   361 
   368 
   362     return helper.responses.respond(request, template, context)
   369     return helper.responses.respond(request, template, context)
   363 
   370