Add full list of accepted students
authorSverre Rabbelier <sverre@rabbelier.nl>
Fri, 01 May 2009 00:35:06 +0200
changeset 2292 80361f34c457
parent 2291 3e21586df316
child 2293 57fab599444a
Add full list of accepted students Patch by: Daniel Hans
app/soc/templates/soc/student_project/list/heading_all.html
app/soc/templates/soc/student_project/list/row_all.html
app/soc/views/models/program.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/student_project/list/heading_all.html	Fri May 01 00:35:06 2009 +0200
@@ -0,0 +1,7 @@
+<tr align="left">
+  <th class="first" align="right">Student</th>
+  <th>Title</th>
+  <th>Mentor</th>
+  <th>Organization</th>
+  <th>Status</th>
+</tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/student_project/list/row_all.html	Fri May 01 00:35:06 2009 +0200
@@ -0,0 +1,11 @@
+<tr class="off" onmouseover="this.className='on'; do_redirect=true" onmouseout="this.className='off'" 
+onclick="if (do_redirect) document.location.href='{{ list.redirect }}'" name="name">
+  <td align="right"><div class="name"><a class="noul"
+         href="{{ list.redirect }}" onclick="do_redirect=false">{{ list.item.student.name }}</a>
+     </div>
+  </td>
+  <td><div class="title">{{ list.item.title }}</a></div></td>
+  <td><div class="title">{{ list.item.mentor.name }}</a></div></td>
+  <td><div class="title">{{ list.item.scope.name }}</a></div></td>
+  <td><div class="status">{{ list.item.status }}</a></div></td>
+</tr>
--- a/app/soc/views/models/program.py	Fri May 01 00:32:18 2009 +0200
+++ b/app/soc/views/models/program.py	Fri May 01 00:35:06 2009 +0200
@@ -18,6 +18,7 @@
 """
 
 __authors__ = [
+    '"Daniel Hans" <daniel.m.hans@gmail.com>',
     '"Sverre Rabbelier" <sverre@rabbelier.nl>',
     '"Lennard de Rijk" <ljvderijk@gmail.com>',
   ]
@@ -74,6 +75,10 @@
 
   DEF_SLOTS_ALLOCATION_MSG = ugettext("Use this view to assign slots.")
 
+  DEF_ACCEPTED_PROJECTS_MSG_FMT = ugettext("These projects have been"
+      " accepted into %(name)s. You can learn more about each project"
+      " by visiting the links below.")
+
   def __init__(self, params=None):
     """Defines the fields and methods required for the base View class
     to provide the user with list, public, create, edit and delete views.
@@ -95,6 +100,8 @@
     rights['assigned_proposals'] = ['checkIsHostForProgram']
     rights['accepted_orgs'] = [('checkIsAfterEvent',
         ['accepted_organization_announced_deadline', '__all__'])]
+    rights['list_projects'] = [('checkIsAfterEvent',
+        ['accepted_students_announced_deadline', '__all__'])]
 
     new_params = {}
     new_params['logic'] = soc.logic.models.program.logic
@@ -127,6 +134,9 @@
         (r'^%(url_name)s/(?P<access_type>accepted_orgs)/%(key_fields)s$',
           'soc.views.models.%(module_name)s.accepted_orgs',
           "List all accepted organizations"),
+        (r'^%(url_name)s/(?P<access_type>list_projects)/%(key_fields)s$',
+          'soc.views.models.%(module_name)s.list_projects',
+          "List all student projects"),
         ]
 
     new_params['extra_django_patterns'] = patterns
@@ -272,6 +282,46 @@
 
   @decorators.merge_params
   @decorators.check_access
+  def acceptedProjects(self, request, access_type,
+		       page_name=None, params=None, filter=None, **kwargs):
+    """See base.View.list.
+    """
+    contents = []
+    logic = params['logic']
+
+    program_entity = logic.getFromKeyFieldsOr404(kwargs)
+
+    filter = {
+	'status': 'accepted',
+	'program': program_entity }
+
+    fmt = {'name': program_entity.name}
+    description = self.DEF_ACCEPTED_PROJECTS_MSG_FMT % fmt
+
+    from soc.views.models import student_project as sp_view
+
+    ap_params = sp_view.view.getParams().copy() # accepted projects
+
+    fun =  soc.cache.logic.cache(self._getData)
+    ap_logic = ap_params['logic']
+    entities = fun(logic.getModel(), filter, order=None, logic=ap_logic)
+    
+    ap_list = dicts.rename(ap_params, ap_params['list_params'])
+    ap_list['action'] = (redirects.getPublicRedirect, ap_params)
+    ap_list['description'] = description
+    ap_list['pagination'] = 'soc/list/no_pagination.html'
+    ap_list['heading'] = 'soc/student_project/list/heading_all.html'
+    ap_list['row'] = 'soc/student_project/list/row_all.html'
+    ap_list['data'] = entities
+
+    contents.append(ap_list)
+
+    params = params.copy()
+
+    return self._list(request, params, contents, page_name)
+
+  @decorators.merge_params
+  @decorators.check_access
   def slots(self, request, acces_type, page_name=None, params=None, **kwargs):
     """Returns a JSON object with all orgs allocation.
 
@@ -712,6 +762,13 @@
         items += [('/org/apply_mentor/%s' % (program_entity.key().id_or_name()),
          "Apply to become a Mentor", 'any_access')]
 
+    deadline = 'accepted_students_announced_deadline'
+
+    if timeline_helper.isAfterEvent(timeline_entity, deadline):
+      items += [(redirects.getListProjectsRedirect(program_entity,
+          {'url_name':'program'}),
+          "List all student projects", 'any_access')]
+
     return items
 
   def _getStudentEntries(self, program_entity, student_entity, 
@@ -762,6 +819,7 @@
 view = View()
 
 accepted_orgs = decorators.view(view.acceptedOrgs)
+list_projects = decorators.view(view.acceptedProjects)
 admin = decorators.view(view.admin)
 assign_slots = decorators.view(view.assignSlots)
 assigned_proposals = decorators.view(view.assignedProposals)