200 For params see base.View.public(). |
200 For params see base.View.public(). |
201 """ |
201 """ |
202 |
202 |
203 from soc.logic.models.ranker_root import logic as ranker_root_logic |
203 from soc.logic.models.ranker_root import logic as ranker_root_logic |
204 from soc.models import student_proposal |
204 from soc.models import student_proposal |
|
205 from soc.views.helper import list_info as list_info_helper |
205 from soc.views.models import student_proposal as student_proposal_view |
206 from soc.views.models import student_proposal as student_proposal_view |
206 |
207 |
207 try: |
208 try: |
208 org_entity = self._logic.getFromKeyFieldsOr404(kwargs) |
209 org_entity = self._logic.getFromKeyFieldsOr404(kwargs) |
209 except out_of_band.Error, error: |
210 except out_of_band.Error, error: |
210 return helper.responses.errorResponse( |
211 return helper.responses.errorResponse( |
211 error, request, template=params['error_public']) |
212 error, request, template=params['error_public']) |
212 |
213 |
|
214 context = {} |
|
215 context['entity'] = org_entity |
|
216 |
213 list_params = student_proposal_view.view.getParams().copy() |
217 list_params = student_proposal_view.view.getParams().copy() |
|
218 list_params['list_template'] = 'soc/student_proposal/list_for_org.html' |
214 |
219 |
215 ranked_params = list_params.copy()# ranked proposals |
220 ranked_params = list_params.copy()# ranked proposals |
216 ranked_params['list_row'] = ('soc/%(module_name)s/list/' |
221 ranked_params['list_row'] = ('soc/%(module_name)s/list/' |
217 'detailed_row.html' % list_params) |
222 'detailed_row.html' % list_params) |
218 ranked_params['list_heading'] = ('soc/%(module_name)s/list/' |
223 ranked_params['list_heading'] = ('soc/%(module_name)s/list/' |
248 ranks = [rank+1 for rank in ranker.FindRanks(scores)] |
253 ranks = [rank+1 for rank in ranker.FindRanks(scores)] |
249 |
254 |
250 # link the proposals to the rank |
255 # link the proposals to the rank |
251 ranking = dict([i for i in itertools.izip(proposals, ranks)]) |
256 ranking = dict([i for i in itertools.izip(proposals, ranks)]) |
252 |
257 |
253 # update the prop_list with the ranking information |
258 assigned_proposals = [] |
254 prop_list['info'] = ((lambda item, cache: {'rank': cache[item]}), ranking) |
259 |
|
260 # only when the program allows allocations to be seen we should color the list |
|
261 if org_entity.scope.allocations_visible: |
|
262 # get the limit and offset for the list |
|
263 limit, offset = lists.getLimitAndOffset(request, 'offset_0', 'limit_0') |
|
264 |
|
265 # determine the amount of proposals to color |
|
266 to_color = max(0, org_entity.slots - offset) |
|
267 assigned_proposals = proposals[0:to_color] |
|
268 |
|
269 # show the amount of slots assigned on the webpage |
|
270 context['slots_visible'] = True |
|
271 |
|
272 # update the prop_list with the ranking and coloring information |
|
273 prop_list['info'] = (list_info_helper.getStudentProposalInfo(ranking, |
|
274 assigned_proposals), None) |
255 |
275 |
256 new_params = list_params.copy() # new proposals |
276 new_params = list_params.copy() # new proposals |
257 new_params['list_description'] = 'List of new %s send to %s ' % ( |
277 new_params['list_description'] = 'List of new %s send to %s ' % ( |
258 new_params['name_plural'], org_entity.name) |
278 new_params['name_plural'], org_entity.name) |
259 new_params['list_action'] = (redirects.getReviewRedirect, new_params) |
279 new_params['list_action'] = (redirects.getReviewRedirect, new_params) |
262 'status': 'new'} |
282 'status': 'new'} |
263 |
283 |
264 contents = [] |
284 contents = [] |
265 new_list = lists.getListContent( |
285 new_list = lists.getListContent( |
266 request, new_params, filter, idx=1, need_content=True) |
286 request, new_params, filter, idx=1, need_content=True) |
267 |
287 |
268 # fill contents with all the needed lists |
288 # fill contents with all the needed lists |
269 if new_list != None: |
289 if new_list != None: |
270 contents.append(new_list) |
290 contents.append(new_list) |
271 contents.append(prop_list) |
291 contents.append(prop_list) |
272 |
292 |
273 # call the _list method from base to display the list |
293 # call the _list method from base to display the list |
274 return self._list(request, list_params, contents, page_name) |
294 return self._list(request, list_params, contents, page_name, context) |
275 |
295 |
276 @decorators.merge_params |
296 @decorators.merge_params |
277 @decorators.check_access |
297 @decorators.check_access |
278 def listPublic(self, request, access_type, page_name=None, |
298 def listPublic(self, request, access_type, page_name=None, |
279 params=None, filter=None, **kwargs): |
299 params=None, filter=None, **kwargs): |