# HG changeset patch # User Lennard de Rijk # Date 1248772991 -7200 # Node ID 506cda0463e872b573a18651bc5191e93474f598 # Parent 08ec7ca16dce785acffe9aabfd396ba1055beb5d Added columns to the manage project page that show the amount of evaluations. The total possible amount of evaluations that is shown is based on surveys which have at least one Record. diff -r 08ec7ca16dce -r 506cda0463e8 app/soc/templates/soc/student_project/list/heading_manage.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/templates/soc/student_project/list/heading_manage.html Tue Jul 28 11:23:11 2009 +0200 @@ -0,0 +1,8 @@ + + Student + Title + Mentor + Mentor Evaluations (on file/total) + Student Evaluations (on file/total) + Status + diff -r 08ec7ca16dce -r 506cda0463e8 app/soc/templates/soc/student_project/list/row_manage.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/templates/soc/student_project/list/row_manage.html Tue Jul 28 11:23:11 2009 +0200 @@ -0,0 +1,20 @@ + +
{{ list.item.student.name }} +
+ +
{{ list.item.title }}
+
{{ list.item.mentor.name }}
+
+ {{ list.info.grading_project_surveys_completed }} + / + {{ list.info.grading_project_surveys_total }} +
+
+ {{ list.info.project_surveys_completed }} + / + {{ list.info.project_surveys_total }} +
+
{{ list.item.status }}
+ diff -r 08ec7ca16dce -r 506cda0463e8 app/soc/views/helper/list_info.py --- a/app/soc/views/helper/list_info.py Tue Jul 28 11:20:42 2009 +0200 +++ b/app/soc/views/helper/list_info.py Tue Jul 28 11:23:11 2009 +0200 @@ -31,7 +31,7 @@ """ def wrapper(item, _): - """Decorator wrapper method. + """Wrapper method. """ info = {'rank': ranking[item.key()]} @@ -42,3 +42,56 @@ return info return wrapper + + +def getStudentProjectSurveyInfo(program_entity): + """Returns a function that returns information used in a Student Project + table to show how many evaluations have been available and how + many have been taken. + + Args: + program_entity: the program to check the total amount of + (Grading)ProjctSurveys for + """ + + from soc.logic.models.survey import grading_logic as grading_survey_logic + from soc.logic.models.survey import project_logic as project_survey_logic + + fields = {'scope_path': program_entity.key().id_or_name()} + + # count the number of have been active ProjectSurveys + project_surveys = project_survey_logic.getForFields(fields) + project_survey_count = len(project_surveys) + + for project_survey in project_surveys: + if not project_survey_logic.hasAtLeastOneRecord(project_survey): + project_survey_count = project_survey_count - 1 + + # count the number of have been active GradingProjectSurveys + grading_surveys = grading_survey_logic.getForFields(fields) + grading_survey_count = len(grading_surveys) + + for grading_survey in grading_surveys: + if not grading_survey_logic.hasAtLeastOneRecord(grading_survey): + grading_survey_count = grading_survey_count - 1 + + def wrapper(item, _): + """Wrapper method. + """ + + from soc.logic.models.survey_record import grading_logic + from soc.logic.models.survey_record import project_logic + + fields = {'project': item} + + # count the amount of records we have on store for this project + project_record_count = project_logic.getQueryForFields(fields).count() + grading_record_count = grading_logic.getQueryForFields(fields).count() + + info = {'project_surveys_total': project_survey_count, + 'project_surveys_completed': project_record_count, + 'grading_project_surveys_total': grading_survey_count, + 'grading_project_surveys_completed': grading_record_count} + + return info + return wrapper diff -r 08ec7ca16dce -r 506cda0463e8 app/soc/views/models/student_project.py --- a/app/soc/views/models/student_project.py Tue Jul 28 11:20:42 2009 +0200 +++ b/app/soc/views/models/student_project.py Tue Jul 28 11:23:11 2009 +0200 @@ -137,6 +137,10 @@ new_params['edit_template'] = 'soc/student_project/edit.html' new_params['manage_template'] = 'soc/student_project/manage.html' + new_params['manage_overview_heading'] = \ + 'soc/student_project/list/heading_manage.html' + new_params['manage_overview_row'] = \ + 'soc/student_project/list/row_manage.html' params = dicts.merge(params, new_params) @@ -479,6 +483,8 @@ For params see base.View().public() """ + from soc.views.helper import list_info + # make sure the organization exists org_entity = org_logic.getFromKeyNameOr404(kwargs['scope_path']) fields = {'scope': org_entity} @@ -489,6 +495,10 @@ context['page_name'] = '%s %s' % (page_name, org_entity.name) list_params = params.copy() + list_params['list_heading'] = params['manage_overview_heading'] + list_params['list_row'] = params['manage_overview_row'] + list_params['list_info'] = ( + list_info.getStudentProjectSurveyInfo(org_entity.scope), None) #list all active projects fields['status'] = 'accepted'