app/soc/views/models/base.py
changeset 933 7331232d6356
parent 880 d67557c612de
child 934 9fcc08971efe
equal deleted inserted replaced
932:2b72d0315254 933:7331232d6356
   504     self._logic.delete(entity)
   504     self._logic.delete(entity)
   505     redirect = params['delete_redirect']
   505     redirect = params['delete_redirect']
   506 
   506 
   507     return http.HttpResponseRedirect(redirect)
   507     return http.HttpResponseRedirect(redirect)
   508 
   508 
   509   def select(self, request, view, redirect, page_name=None, params=None):
   509   def select(self, request, view, redirect,
       
   510              page_name=None, params=None, filter=None):
   510     """Displays a list page allowing the user to select an entity.
   511     """Displays a list page allowing the user to select an entity.
   511 
   512 
   512     After having selected the Scope, the user is redirected to the
   513     After having selected the Scope, the user is redirected to the
   513     'create a new entity' page with the scope_path set appropriately.
   514     'create a new entity' page with the scope_path set appropriately.
   514 
   515 
   518       The params dictionary is passed to self._list as well, refer
   519       The params dictionary is passed to self._list as well, refer
   519         to its docstring for details on how it uses it.
   520         to its docstring for details on how it uses it.
   520 
   521 
   521     Args:
   522     Args:
   522       request: the standard Django HTTP request object
   523       request: the standard Django HTTP request object
   523       page_name: the page name displayed in templates as page and header title
   524       view: the view for which to generate the select page
   524       params: a dict with params for this View
   525       redirect: the redirect to use
       
   526       page_name: the page name displayed in templates as page and header title
       
   527       params: a dict with params for this View
       
   528       filter: a filter that all displayed entities should satisfy
   525     """
   529     """
   526 
   530 
   527     params = dicts.merge(params, view.getParams())
   531     params = dicts.merge(params, view.getParams())
   528     params = dicts.merge(params, self._params)
   532     params = dicts.merge(params, self._params)
   529     params['list_action'] = (redirect, self._params)
   533     params['list_action'] = (redirect, self._params)
   530     params['list_description'] = self.DEF_CREATE_INSTRUCTION_MSG_FMT % (
   534     params['list_description'] = self.DEF_CREATE_INSTRUCTION_MSG_FMT % (
   531         params['name'], self._params['name'])
   535         params['name'], self._params['name'])
   532 
   536 
   533     content = helper.lists.getListContent(request, params)
   537     content = helper.lists.getListContent(request, params, filter=filter)
   534     contents = [content]
   538     contents = [content]
   535 
   539 
   536     return self._list(request, params, contents, page_name)
   540     return self._list(request, params, contents, page_name)
       
   541 
       
   542   @decorators.merge_params
       
   543   @decorators.check_access
       
   544   def pick(self, request, acces_type, page_name=None, params=None):
       
   545     """Displays a list page allowing the user to select an entity.
       
   546 
       
   547     After having selected an entity, the user is redirected to the
       
   548     return_url as specified in the GET args.
       
   549 
       
   550     Params usage:
       
   551       The params dictionary is passed to self.select, refer
       
   552         to its docstring for details on how it uses it.
       
   553 
       
   554     Args:
       
   555       request: the standard Django HTTP request object
       
   556       page_name: the page name displayed in templates as page and header title
       
   557       params: a dict with params for this View
       
   558     """
       
   559 
       
   560     get_dict = request.GET
       
   561     filter = {}
       
   562 
       
   563     # scope_path is not required
       
   564     scope_path = get_dict.get('scope_path', None)
       
   565     return_url = get_dict['continue']
       
   566     field = get_dict['field']
       
   567 
       
   568     if scope_path:
       
   569       filter['scope_path'] = scope_path
       
   570 
       
   571     redirect = redirects.getReturnRedirect(return_url, field)
       
   572     return self.select(request, self, redirect, page_name=page_name,
       
   573                        params=params, filter=filter)
   537 
   574 
   538   def _editPost(self, request, entity, fields):
   575   def _editPost(self, request, entity, fields):
   539     """Performs any required processing on the entity to post its edit page.
   576     """Performs any required processing on the entity to post its edit page.
   540 
   577 
   541     Args:
   578     Args: