app/soc/views/models/student_project.py
changeset 2688 dfe0439a0711
parent 2685 506cda0463e8
child 2689 18d8486fd411
equal deleted inserted replaced
2687:1e2bcc7f6d3a 2688:dfe0439a0711
   336         dynaproperties = dynaproperties,
   336         dynaproperties = dynaproperties,
   337     )
   337     )
   338 
   338 
   339     params['additional_mentor_form'] = additional_mentor_form
   339     params['additional_mentor_form'] = additional_mentor_form
   340 
   340 
       
   341     context['evaluation_list'] = self._getEvaluationLists(request, params,
       
   342                                                           entity)
       
   343 
   341     if request.POST:
   344     if request.POST:
   342       return self.managePost(request, template, context, params, entity,
   345       return self.managePost(request, template, context, params, entity,
   343                              **kwargs)
   346                              **kwargs)
   344     else: #request.GET
   347     else: #request.GET
   345       return self.manageGet(request, template, context, params, entity,
   348       return self.manageGet(request, template, context, params, entity,
   346                             **kwargs)
   349                             **kwargs)
       
   350 
       
   351   def _getEvaluationLists(self, request, params, entity):
       
   352     """Returns List Object containing the list to be shown on the Student 
       
   353     Project's manage page.
       
   354 
       
   355     This list contains all Surveys that have at least one record and will also 
       
   356     contain information about the presence (or absence) of a accompanying 
       
   357     record for the given Student Project.
       
   358 
       
   359     Args:
       
   360       request: Django HTTP Request Object
       
   361       params: the params dict for this View
       
   362       entity: a StudentProject entity for which the Surveys(Records) should be
       
   363               retrieved
       
   364 
       
   365     Returns:
       
   366       A List Object as specified by this method.
       
   367     """
       
   368 
       
   369     from soc.views.helper import list_info
       
   370     from soc.views.models.grading_project_survey import view as \
       
   371         grading_survey_view
       
   372     from soc.views.models.project_survey import view as project_survey_view
       
   373 
       
   374     fields = {'scope_path': entity.program.key().id_or_name()}
       
   375 
       
   376     # get the GradingProjectSurvey list
       
   377     gps_params = grading_survey_view.getParams().copy()
       
   378     gps_params['list_key_order'] = None
       
   379     gps_params['list_heading'] = gps_params['manage_student_project_heading']
       
   380     gps_params['list_row'] = gps_params['manage_student_project_row']
       
   381     gps_params['list_info'] = (
       
   382         list_info.getProjectSurveyInfoForProject(entity, gps_params), None)
       
   383 
       
   384     #list all surveys for this Project's Program
       
   385     fields['scope_path'] = entity.program.key().id_or_name()
       
   386     gps_params['list_description'] = \
       
   387         'List of all Mentor Evaluations for this Project'
       
   388     gps_params['list_action'] = None
       
   389 
       
   390     gps_list = lists.getListContent(
       
   391         request, gps_params, fields, idx=0)
       
   392 
       
   393     # get the ProjectSurvey list
       
   394     ps_params = project_survey_view.getParams().copy()
       
   395     ps_params['list_key_order'] = None
       
   396     ps_params['list_heading'] = ps_params['manage_student_project_heading']
       
   397     ps_params['list_row'] = ps_params['manage_student_project_row']
       
   398     ps_params['list_info'] = (
       
   399         list_info.getProjectSurveyInfoForProject(entity, ps_params), None)
       
   400 
       
   401     ps_params['list_description'] = \
       
   402         'List of all Student Evaluations for this Project'
       
   403     ps_params['list_action'] = None
       
   404 
       
   405     #list all surveys for this Project's Program
       
   406     fields['scope_path'] = entity.program.key().id_or_name()
       
   407     ps_list = lists.getListContent(
       
   408         request, ps_params, fields, idx=1)
       
   409 
       
   410     # store both lists in the content
       
   411     content = [gps_list, ps_list]
       
   412 
       
   413     for list in content:
       
   414       # remove all the surveys that have no records attached
       
   415       list['data'] = [i for i in list['data'] if
       
   416                       list['logic'].hasAtLeastOneRecord(i)]
       
   417 
       
   418     # return the List Object with the filtered list content
       
   419     return soc.logic.lists.Lists(content)
   347 
   420 
   348   def manageGet(self, request, template, context, params, entity, **kwargs):
   421   def manageGet(self, request, template, context, params, entity, **kwargs):
   349     """Handles the GET request for the project's manage page.
   422     """Handles the GET request for the project's manage page.
   350 
   423 
   351     Args:
   424     Args: