# HG changeset patch # User Lennard de Rijk # Date 1236341335 0 # Node ID 4b48cd4e4aa9ebcd97eb7e83a6cfb1a75036df54 # Parent 83010029e2fbe183c6595bb0fd0e41a536c491f8 Added a rank column to the proposals list. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 83010029e2fb -r 4b48cd4e4aa9 app/soc/templates/soc/student_proposal/list/detailed_heading.html --- a/app/soc/templates/soc/student_proposal/list/detailed_heading.html Thu Mar 05 22:30:58 2009 +0000 +++ b/app/soc/templates/soc/student_proposal/list/detailed_heading.html Fri Mar 06 12:08:55 2009 +0000 @@ -1,4 +1,5 @@ + Rank Student Title Status diff -r 83010029e2fb -r 4b48cd4e4aa9 app/soc/templates/soc/student_proposal/list/detailed_row.html --- a/app/soc/templates/soc/student_proposal/list/detailed_row.html Thu Mar 05 22:30:58 2009 +0000 +++ b/app/soc/templates/soc/student_proposal/list/detailed_row.html Fri Mar 06 12:08:55 2009 +0000 @@ -1,5 +1,6 @@ +
{{ list.info.rank }}
{{ list.item.scope.link_id }}
diff -r 83010029e2fb -r 4b48cd4e4aa9 app/soc/views/models/organization.py --- a/app/soc/views/models/organization.py Thu Mar 05 22:30:58 2009 +0000 +++ b/app/soc/views/models/organization.py Fri Mar 06 12:08:55 2009 +0000 @@ -24,6 +24,8 @@ ] +import itertools + from django import forms from django.utils.translation import ugettext @@ -186,6 +188,8 @@ For params see base.View.public(). """ + from soc.logic.models.ranker_root import logic as ranker_root_logic + from soc.models import student_proposal from soc.views.models import student_proposal as student_proposal_view try: @@ -195,12 +199,12 @@ error, request, template=params['error_public']) list_params = student_proposal_view.view.getParams().copy() - list_params['list_row'] = ('soc/%(module_name)s/list/' - 'detailed_row.html' % list_params) - list_params['list_heading'] = ('soc/%(module_name)s/list/' - 'detailed_heading.html' % list_params) ranked_params = list_params.copy()# ranked proposals + ranked_params['list_row'] = ('soc/%(module_name)s/list/' + 'detailed_row.html' % list_params) + ranked_params['list_heading'] = ('soc/%(module_name)s/list/' + 'detailed_heading.html' % list_params) ranked_params['list_description'] = 'List of %s send to %s ' % ( ranked_params['name_plural'], org_entity.name) ranked_params['list_action'] = (redirects.getReviewRedirect, ranked_params) @@ -216,12 +220,34 @@ prop_list = lists.getListContent( request, ranked_params, filter, order=order, idx=0) + proposals = prop_list['data'] + + # get a list of scores + scores = [[proposal.score] for proposal in proposals] + + # retrieve the ranker + fields = {'link_id': student_proposal.DEF_RANKER_NAME, + 'scope': org_entity} + + ranker_root = ranker_root_logic.getForFields(fields, unique=True) + ranker = ranker_root_logic.getRootFromEntity(ranker_root) + + # retrieve the ranks for these scores + ranks = [rank+1 for rank in ranker.FindRanks(scores)] + + # link the proposals to the rank + ranking = dict([i for i in itertools.izip(proposals, ranks)]) + + # update the prop_list with the ranking information + prop_list['info'] = ((lambda item, cache: {'rank': cache[item]}), ranking) + new_params = list_params.copy() # new proposals new_params['list_description'] = 'List of new %s send to %s ' %( new_params['name_plural'], org_entity.name) new_params['list_action'] = (redirects.getReviewRedirect, new_params) - filter['status'] = 'new' + filter = {'org': org_entity, + 'status': 'new'} new_list = lists.getListContent( request, new_params, filter, idx=1)