Added list of Surveys to the Project's manage page.
authorLennard de Rijk <ljvderijk@gmail.com>
Thu, 30 Jul 2009 09:53:22 +0200
changeset 2688 dfe0439a0711
parent 2687 1e2bcc7f6d3a
child 2689 18d8486fd411
Added list of Surveys to the Project's manage page. This list will show wether or not a Survey has been taken and will also feature links to (re)take a Survey and in the near future to see the actual SurveyRecord. Note that the take Survey link is working however Org Admins will receive an access denied message when following this link.
app/soc/templates/soc/student_project/manage.html
app/soc/views/models/student_project.py
--- a/app/soc/templates/soc/student_project/manage.html	Thu Jul 30 09:43:15 2009 +0200
+++ b/app/soc/templates/soc/student_project/manage.html	Thu Jul 30 09:53:22 2009 +0200
@@ -15,16 +15,14 @@
 {% load forms_helpers %}
 
 {% block body %}
-<p>
-<p>
 {% block instructions %}
-Please use this form to change the Mentor for the Student Project.
+Use this page to manage the Student Project. You can (re)assign Mentors here and check the status of the evaluations.
 {% endblock %}
 
-{% if error_message %}
-  <div class="error">{{ error_message|safe }}</div>
-{% endif %}
-
+<p>
+<b>Primary Mentor</b><br />
+In this section you can assign a new Primary Mentor.
+Note that if you select a co-Mentor from this list that Mentor will be removed from the co-Mentors.
 <form method="POST">
   <table>
     {% as_table mentor_edit_form %}
@@ -43,10 +41,12 @@
   </tr>
  </table>
 </form>
-<p/>
+</p>
 
-<b> Co-Mentors </b><br/>
-
+<p>
+<b>Co-Mentors</b><br/>
+In this section you can add/remove co-mentors for this project.
+Co-mentors usually play a vital role in the success of a project, however they are not responsible for taking evaluations.
 <table>
   {% for mentor in additional_mentors %}
     <tr>
@@ -77,4 +77,19 @@
   </tr>
  </table>
 </form>
+</p>
+
+<p>
+<b>Evaluations</b><br />
+This section contains the Mentor and Student Evaluations.
+From here you can view the Mentor and Student Evaluations and if possible (re)take the evaluations given by your Mentor.
+
+{% with evaluation_list as list %}
+  {% for list_number in list.lists %}
+    <p>
+      {% include list.nextList %}
+    </p>
+  {% endfor %}
+{% endwith %}
+</p>
 {% endblock %}
--- a/app/soc/views/models/student_project.py	Thu Jul 30 09:43:15 2009 +0200
+++ b/app/soc/views/models/student_project.py	Thu Jul 30 09:53:22 2009 +0200
@@ -338,6 +338,9 @@
 
     params['additional_mentor_form'] = additional_mentor_form
 
+    context['evaluation_list'] = self._getEvaluationLists(request, params,
+                                                          entity)
+
     if request.POST:
       return self.managePost(request, template, context, params, entity,
                              **kwargs)
@@ -345,6 +348,76 @@
       return self.manageGet(request, template, context, params, entity,
                             **kwargs)
 
+  def _getEvaluationLists(self, request, params, entity):
+    """Returns List Object containing the list to be shown on the Student 
+    Project's manage page.
+
+    This list contains all Surveys that have at least one record and will also 
+    contain information about the presence (or absence) of a accompanying 
+    record for the given Student Project.
+
+    Args:
+      request: Django HTTP Request Object
+      params: the params dict for this View
+      entity: a StudentProject entity for which the Surveys(Records) should be
+              retrieved
+
+    Returns:
+      A List Object as specified by this method.
+    """
+
+    from soc.views.helper import list_info
+    from soc.views.models.grading_project_survey import view as \
+        grading_survey_view
+    from soc.views.models.project_survey import view as project_survey_view
+
+    fields = {'scope_path': entity.program.key().id_or_name()}
+
+    # get the GradingProjectSurvey list
+    gps_params = grading_survey_view.getParams().copy()
+    gps_params['list_key_order'] = None
+    gps_params['list_heading'] = gps_params['manage_student_project_heading']
+    gps_params['list_row'] = gps_params['manage_student_project_row']
+    gps_params['list_info'] = (
+        list_info.getProjectSurveyInfoForProject(entity, gps_params), None)
+
+    #list all surveys for this Project's Program
+    fields['scope_path'] = entity.program.key().id_or_name()
+    gps_params['list_description'] = \
+        'List of all Mentor Evaluations for this Project'
+    gps_params['list_action'] = None
+
+    gps_list = lists.getListContent(
+        request, gps_params, fields, idx=0)
+
+    # get the ProjectSurvey list
+    ps_params = project_survey_view.getParams().copy()
+    ps_params['list_key_order'] = None
+    ps_params['list_heading'] = ps_params['manage_student_project_heading']
+    ps_params['list_row'] = ps_params['manage_student_project_row']
+    ps_params['list_info'] = (
+        list_info.getProjectSurveyInfoForProject(entity, ps_params), None)
+
+    ps_params['list_description'] = \
+        'List of all Student Evaluations for this Project'
+    ps_params['list_action'] = None
+
+    #list all surveys for this Project's Program
+    fields['scope_path'] = entity.program.key().id_or_name()
+    ps_list = lists.getListContent(
+        request, ps_params, fields, idx=1)
+
+    # store both lists in the content
+    content = [gps_list, ps_list]
+
+    for list in content:
+      # remove all the surveys that have no records attached
+      list['data'] = [i for i in list['data'] if
+                      list['logic'].hasAtLeastOneRecord(i)]
+
+    # return the List Object with the filtered list content
+    return soc.logic.lists.Lists(content)
+
   def manageGet(self, request, template, context, params, entity, **kwargs):
     """Handles the GET request for the project's manage page.