The org list proposals page now shows the amount of assigned slots.
authorLennard de Rijk <ljvderijk@gmail.com>
Wed, 18 Mar 2009 17:18:19 +0000
changeset 1928 8001eee3160f
parent 1927 69a69eaee48d
child 1929 1ce28a2dd71f
The org list proposals page now shows the amount of assigned slots. Also colors the list of possible accepted proposals. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/templates/soc/student_proposal/list/detailed_row.html
app/soc/templates/soc/student_proposal/list_for_org.html
app/soc/views/models/organization.py
--- a/app/soc/templates/soc/student_proposal/list/detailed_row.html	Wed Mar 18 17:17:20 2009 +0000
+++ b/app/soc/templates/soc/student_proposal/list/detailed_row.html	Wed Mar 18 17:18:19 2009 +0000
@@ -1,4 +1,8 @@
-<tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" 
+{% ifequal list.info.item_class "selected" %}
+  <tr class="assignedslot" onmouseover="this.className='on'" onmouseout="this.className='assignedslot'" 
+{% else %}
+  <tr class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" 
+{% endifequal %}
 onclick="document.location.href='{{ list.redirect }}'" name="name">
   <td><div class="rank">{{ list.info.rank }}</a></div></td>
   <td align="right"><div class="name"><a class="noul"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/student_proposal/list_for_org.html	Wed Mar 18 17:18:19 2009 +0000
@@ -0,0 +1,24 @@
+{% extends "soc/models/list.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% load forms_helpers %}
+{% block body %}
+
+{% if slots_visible %}
+<span="plaintext">Slots assigned: {{ entity.slots }}</span>
+{% endif %}
+
+{{ block.super}}
+
+{% endblock %}
--- a/app/soc/views/models/organization.py	Wed Mar 18 17:17:20 2009 +0000
+++ b/app/soc/views/models/organization.py	Wed Mar 18 17:18:19 2009 +0000
@@ -202,6 +202,7 @@
 
     from soc.logic.models.ranker_root import logic as ranker_root_logic
     from soc.models import student_proposal
+    from soc.views.helper import list_info as list_info_helper
     from soc.views.models import student_proposal as student_proposal_view
 
     try:
@@ -210,7 +211,11 @@
       return helper.responses.errorResponse(
           error, request, template=params['error_public'])
 
+    context = {}
+    context['entity'] = org_entity
+
     list_params = student_proposal_view.view.getParams().copy()
+    list_params['list_template'] = 'soc/student_proposal/list_for_org.html'
 
     ranked_params = list_params.copy()# ranked proposals
     ranked_params['list_row'] = ('soc/%(module_name)s/list/'
@@ -250,8 +255,23 @@
     # 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)
+    assigned_proposals = []
+
+    # only when the program allows allocations to be seen we should color the list
+    if org_entity.scope.allocations_visible:
+      # get the limit and offset for the list
+      limit, offset = lists.getLimitAndOffset(request, 'offset_0', 'limit_0')
+
+      # determine the amount of proposals to color
+      to_color = max(0, org_entity.slots - offset)
+      assigned_proposals = proposals[0:to_color]
+
+      # show the amount of slots assigned on the webpage
+      context['slots_visible'] = True
+
+    # update the prop_list with the ranking and coloring information
+    prop_list['info'] = (list_info_helper.getStudentProposalInfo(ranking,
+        assigned_proposals), None)
 
     new_params = list_params.copy() # new proposals
     new_params['list_description'] = 'List of new %s send to %s ' % (
@@ -264,14 +284,14 @@
     contents = []
     new_list = lists.getListContent(
         request, new_params, filter, idx=1, need_content=True)
-    
+
     # fill contents with all the needed lists
     if new_list != None:
       contents.append(new_list)
     contents.append(prop_list)
 
     # call the _list method from base to display the list
-    return self._list(request, list_params, contents, page_name)
+    return self._list(request, list_params, contents, page_name, context)
 
   @decorators.merge_params
   @decorators.check_access