app/soc/views/models/organization.py
changeset 1668 e3780ee24322
parent 1641 c2201decd4b4
child 1676 a3c33bef2ea8
equal deleted inserted replaced
1667:95bc81b4cd5c 1668:e3780ee24322
   181     For params see base.View.public().
   181     For params see base.View.public().
   182     """
   182     """
   183 
   183 
   184     from soc.views.models import student_proposal as student_proposal_view
   184     from soc.views.models import student_proposal as student_proposal_view
   185 
   185 
   186     org_entity = org_logic.logic.getFromKeyFields(kwargs)
   186     try:
       
   187       org_entity = self._logic.getFromKeyFieldsOr404(kwargs)
       
   188     except out_of_band.Error, error:
       
   189       return helper.responses.errorResponse(
       
   190           error, request, template=params['error_public'])
       
   191 
       
   192     list_params = student_proposal_view.view.getParams().copy()
       
   193     list_params['list_row'] = ('soc/%(module_name)s/list/'
       
   194         'detailed_row.html' % list_params)
       
   195     list_params['list_heading'] = ('soc/%(module_name)s/list/'
       
   196         'detailed_heading.html' % list_params)
       
   197 
       
   198     ranked_params = list_params.copy()# ranked proposals
       
   199     ranked_params['list_description'] = 'List of %s send to %s ' % (
       
   200         ranked_params['name_plural'], org_entity.name)
       
   201     ranked_params['list_action'] = (redirects.getReviewRedirect, ranked_params)
   187 
   202 
   188     filter = {'org' : org_entity,
   203     filter = {'org' : org_entity,
   189               'status': ['new', 'pending', 'accepted']}
   204               'status': ['pending', 'accepted']}
   190 
   205 
   191     list_params = student_proposal_view.view.getParams().copy()
   206     # order by descending score
   192     list_params['list_description'] = 'List of %s send to %s ' % (
   207     order = ['-score']
   193         list_params['name_plural'], org_entity.name)
   208 
   194     list_params['list_action'] = (redirects.getPublicRedirect, list_params)
   209     prop_list = lists.getListContent(
   195 
   210         request, ranked_params, filter, order=order, idx=0)
   196     return self.list(request, access_type=access_type, page_name=page_name,
   211 
   197                      params=list_params, filter=filter, **kwargs)
   212     new_params = list_params.copy() # new proposals
       
   213     new_params['list_description'] = 'List of new %s send to %s ' %(
       
   214         new_params['name_plural'], org_entity.name)
       
   215     new_params['list_action'] = (redirects.getReviewRedirect, new_params)
       
   216 
       
   217     filter['status'] = 'new'
       
   218 
       
   219     new_list = lists.getListContent(
       
   220         request, new_params, filter, idx=1)
       
   221 
       
   222     # fill contents with all the needed lists
       
   223     contents = [prop_list, new_list]
       
   224 
       
   225     # call the _list method from base to display the list
       
   226     return self._list(request, list_params, contents, page_name)
   198 
   227 
   199   @decorators.merge_params
   228   @decorators.merge_params
   200   @decorators.check_access
   229   @decorators.check_access
   201   def listPublic(self, request, access_type, page_name=None,
   230   def listPublic(self, request, access_type, page_name=None,
   202                  params=None, filter=None, **kwargs):
   231                  params=None, filter=None, **kwargs):