app/soc/views/models/program.py
changeset 2127 1a0167169af3
parent 2121 4f6344dfab28
child 2128 7da77549bdeb
equal deleted inserted replaced
2126:df06ceda7dcc 2127:1a0167169af3
   186 
   186 
   187     params = dicts.merge(params, new_params, sub_merge=True)
   187     params = dicts.merge(params, new_params, sub_merge=True)
   188 
   188 
   189     super(View, self).__init__(params=params)
   189     super(View, self).__init__(params=params)
   190 
   190 
       
   191   def _getAcceptedOrgsList(self, description, params, filter, use_cache):
       
   192     """Returns a list with all accepted orgs.
       
   193 
       
   194     Args:
       
   195       description: the description of the list
       
   196       params: the params to use
       
   197       filter: the filter to use
       
   198       use_cache: whether or not to use the cache
       
   199     """
       
   200 
       
   201     logic = params['logic']
       
   202 
       
   203     order = ['name']
       
   204 
       
   205     if not use_cache:
       
   206       fun = self._getData
       
   207     else:
       
   208       # only cache if all profiles are created
       
   209       fun =  soc.cache.logic.cache(self._getData)
       
   210     entities = fun(logic.getModel(), filter, order, logic)
       
   211 
       
   212     result = dicts.rename(params, params['list_params'])
       
   213     result['action'] = (redirects.getHomeRedirect, params)
       
   214     result['description'] = description
       
   215     result['pagination'] = 'soc/list/no_pagination.html'
       
   216     result['data'] = entities
       
   217 
       
   218     return result
       
   219 
   191   @decorators.merge_params
   220   @decorators.merge_params
   192   @decorators.check_access
   221   @decorators.check_access
   193   def acceptedOrgs(self, request, access_type,
   222   def acceptedOrgs(self, request, access_type,
   194                    page_name=None, params=None, filter=None, **kwargs):
   223                    page_name=None, params=None, filter=None, **kwargs):
   195     """See base.View.list.
   224     """See base.View.list.
   220                                    need_content=True)
   249                                    need_content=True)
   221 
   250 
   222     if aa_list:
   251     if aa_list:
   223       contents.append(aa_list)
   252       contents.append(aa_list)
   224 
   253 
       
   254     use_cache = not aa_list # only cache if there are no aa's left
   225     description = self.DEF_CREATED_ORGS_MSG_FMT % fmt
   255     description = self.DEF_CREATED_ORGS_MSG_FMT % fmt
   226 
   256 
   227     filter['status'] = ['new', 'active']
   257     filter['status'] = ['new', 'active']
   228 
   258 
   229     from soc.views.models.organization import view as org_view
   259     from soc.views.models.organization import view as org_view
   230     ao_params = org_view.getParams().copy() # active orgs
   260     ao_params = org_view.getParams().copy() # active orgs
   231     ao_logic = ao_params['logic']
   261     ao_list = self._getAcceptedOrgsList(description, ao_params, filter, use_cache)
   232 
       
   233     order = ['name']
       
   234 
       
   235     if aa_list:
       
   236       fun = self._getData
       
   237     else:
       
   238       # only cache if all profiles are created
       
   239       fun =  soc.cache.logic.cache(self._getData)
       
   240     entities = fun(ao_logic.getModel(), filter, order, ao_logic)
       
   241 
       
   242     ao_list = dicts.rename(ao_params, ao_params['list_params'])
       
   243     ao_list['action'] = (redirects.getPublicRedirect, ao_params)
       
   244     ao_list['description'] = description
       
   245     ao_list['pagination'] = 'soc/list/no_pagination.html'
       
   246     ao_list['data'] = entities
       
   247 
   262 
   248     contents.append(ao_list)
   263     contents.append(ao_list)
   249 
   264 
   250     params = params.copy()
   265     params = params.copy()
   251     params['list_msg'] = program_entity.accepted_orgs_msg
   266     params['list_msg'] = program_entity.accepted_orgs_msg