# HG changeset patch # User Lennard de Rijk # Date 1249942469 25200 # Node ID b9a146acb9bbb18b09a26ccf788d13c26b80e4ec # Parent 53a3c5f4252a37eef2506372ada69546c07758d9 Enable the project management page to be visited for project in other statusses. This enables org admins to easily view Survey results for projects that have failed. diff -r 53a3c5f4252a -r b9a146acb9bb app/soc/templates/soc/student_project/manage.html --- a/app/soc/templates/soc/student_project/manage.html Sun Aug 09 21:00:32 2009 -0700 +++ b/app/soc/templates/soc/student_project/manage.html Mon Aug 10 15:14:29 2009 -0700 @@ -28,65 +28,67 @@

-

-Primary Mentor
-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. -

- - {% as_table mentor_edit_form %} -
- - - - - - - - -
 
- - - -
-
-

- -

-Co-Mentors
-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. - - {% for mentor in additional_mentors %} +{% ifequal entity.status "accepted" %} +

+ Primary Mentor
+ 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. +
+

+ {% as_table mentor_edit_form %} +
+ - + + + - {% endfor %} -
- {{ mentor.name }} +  
+ - +
- - - - {% as_table additional_mentor_form %} -
+ + + +

+ +

+ Co-Mentors
+ 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. - - - - - - - -
 
- - - -
- -

+ {% for mentor in additional_mentors %} + + + {{ mentor.name }} + + + + + {% endfor %} + + +
+ + {% as_table additional_mentor_form %} +
+ + + + + + + + +
 
+ + + +
+
+

+{% endifequal %}

Evaluations
diff -r 53a3c5f4252a -r b9a146acb9bb app/soc/views/models/student_project.py --- a/app/soc/views/models/student_project.py Sun Aug 09 21:00:32 2009 -0700 +++ b/app/soc/views/models/student_project.py Mon Aug 10 15:14:29 2009 -0700 @@ -74,7 +74,8 @@ rights['list'] = ['checkIsDeveloper'] rights['manage'] = [('checkHasActiveRoleForScope', org_admin_logic), - ('checkStudentProjectHasStatus', [['accepted']])] + ('checkStudentProjectHasStatus', [['accepted', 'failed', 'completed', + 'withdrawn']])] rights['manage_overview'] = [('checkHasActiveRoleForScope', org_admin_logic)] # TODO: lack of better name here! @@ -185,7 +186,6 @@ self._params['student_edit_form'] = student_edit_form - def _editGet(self, request, entity, form): """See base.View._editGet(). """ @@ -351,26 +351,6 @@ return responses.errorResponse( error, request, template=params['error_public']) - get_dict = request.GET - - if 'remove' in get_dict: - # get the mentor to remove - fields = {'link_id': get_dict['remove'], - 'scope': entity.scope} - mentor = mentor_logic.logic.getForFields(fields, unique=True) - - additional_mentors = entity.additional_mentors - # pylint: disable-msg=E1103 - if additional_mentors and mentor.key() in additional_mentors: - # remove the mentor from the additional mentors list - additional_mentors.remove(mentor.key()) - fields = {'additional_mentors': additional_mentors} - project_logic.updateEntityProperties(entity, fields) - - # redirect to the same page without GET arguments - redirect = request.path - return http.HttpResponseRedirect(redirect) - template = params['manage_template'] # get the context for this webpage @@ -380,6 +360,30 @@ entity.student.name()) context['entity'] = entity + + if entity.status == 'accepted': + # only accepted project can have their mentors managed + self._enableMentorManagement(entity, params, context) + + context['evaluation_list'] = self._getEvaluationLists(request, params, + entity) + + if request.POST: + return self.managePost(request, template, context, params, entity, + **kwargs) + else: #request.GET + return self.manageGet(request, template, context, params, entity, + **kwargs) + + def _enableMentorManagement(self, entity, params, context): + """Sets the data required to manage mentors for a StudentProject. + + Args: + entity: StudentProject entity to manage + params: params dict for the manage view + context: context for the manage view + """ + # get all mentors for this organization fields = {'scope': entity.scope, 'status': 'active'} @@ -449,16 +453,6 @@ 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) - else: #request.GET - 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. @@ -536,11 +530,31 @@ rest: see base.View.public() """ - # populate form with the current mentor - initial = {'mentor_id': entity.mentor.link_id} - context['mentor_edit_form'] = params['mentor_edit_form'](initial=initial) + get_dict = request.GET + + if 'remove' in get_dict and entity.status == 'accepted': + # get the mentor to remove + fields = {'link_id': get_dict['remove'], + 'scope': entity.scope} + mentor = mentor_logic.logic.getForFields(fields, unique=True) - context['additional_mentor_form'] = params['additional_mentor_form']() + additional_mentors = entity.additional_mentors + # pylint: disable- msg=E1103 + if additional_mentors and mentor.key() in additional_mentors: + # remove the mentor from the additional mentors list + additional_mentors.remove(mentor.key()) + fields = {'additional_mentors': additional_mentors} + project_logic.updateEntityProperties(entity, fields) + + # redirect to the same page without GET arguments + redirect = request.path + return http.HttpResponseRedirect(redirect) + + if entity.status == 'accepted': + # populate forms with the current mentors set + initial = {'mentor_id': entity.mentor.link_id} + context['mentor_edit_form'] = params['mentor_edit_form'](initial=initial) + context['additional_mentor_form'] = params['additional_mentor_form']() return responses.respond(request, template, context) @@ -555,11 +569,11 @@ post_dict = request.POST - if 'set_mentor' in post_dict: + if 'set_mentor' in post_dict and entity.status == 'accepted': form = params['mentor_edit_form'](post_dict) return self._manageSetMentor(request, template, context, params, entity, form) - elif 'add_additional_mentor' in post_dict: + elif 'add_additional_mentor' in post_dict and entity.status == 'accepted': form = params['additional_mentor_form'](post_dict) return self._manageAddAdditionalMentor(request, template, context, params, entity, form)