app/soc/views/models/student_proposal.py
changeset 1666 cdb7e5581694
parent 1639 170ac4ca078d
child 1715 3ec1a9518452
equal deleted inserted replaced
1665:9d623ebfff0d 1666:cdb7e5581694
   422     # to change his role for this app
   422     # to change his role for this app
   423     choice = request.GET.get('mentor')
   423     choice = request.GET.get('mentor')
   424     if mentor_entity and choice:
   424     if mentor_entity and choice:
   425       self._adjustPossibleMentors(entity, mentor_entity, choice)
   425       self._adjustPossibleMentors(entity, mentor_entity, choice)
   426 
   426 
   427     # set the possible mentors in the context
       
   428     possible_mentors = entity.possible_mentors
       
   429 
       
   430     if not possible_mentors:
       
   431       context['possible_mentors'] = "None"
       
   432     else:
       
   433       mentor_names = []
       
   434 
       
   435       for mentor_key in possible_mentors:
       
   436         mentor = mentor_logic.logic.getFromKeyName(mentor_key.name())
       
   437         mentor_names.append(mentor.name())
       
   438 
       
   439       context['possible_mentors'] = ', '.join(mentor_names)
       
   440 
       
   441     # decide which form to use
   427     # decide which form to use
   442     if org_admin_entity:
   428     if org_admin_entity:
   443       form = params['admin_review_form']
   429       form = params['admin_review_form']
   444     else:
   430     else:
   445       form = params['mentor_review_form']
   431       form = params['mentor_review_form']
   525       # set the mentor field to the current mentor
   511       # set the mentor field to the current mentor
   526       initial['mentor'] = entity.mentor.link_id
   512       initial['mentor'] = entity.mentor.link_id
   527 
   513 
   528     context['form'] = form(initial)
   514     context['form'] = form(initial)
   529     template = params['review_template']
   515     template = params['review_template']
   530     context['mentor'] = mentor
   516 
       
   517     # set the possible mentors in the context
       
   518     possible_mentors = entity.possible_mentors
       
   519 
       
   520     if not possible_mentors:
       
   521       context['possible_mentors'] = "None"
       
   522     else:
       
   523       mentor_names = []
       
   524 
       
   525       for mentor_key in possible_mentors:
       
   526         mentor = mentor_logic.logic.getFromKeyName(mentor_key.name())
       
   527         mentor_names.append(mentor.name())
       
   528 
       
   529       context['possible_mentors'] = ', '.join(mentor_names)
       
   530 
       
   531     if mentor:
       
   532       if mentor.key() in possible_mentors:
       
   533         # show "No longer willing to mentor"
       
   534         context['remove_me_as_mentor'] = True
       
   535       else:
       
   536         # show "I am willing to mentor"
       
   537         context['add_me_as_mentor'] = True
   531 
   538 
   532     return responses.respond(request, template, context=context)
   539     return responses.respond(request, template, context=context)
   533 
   540 
   534   def _adjustPossibleMentors(self, entity, mentor, choice):
   541   def _adjustPossibleMentors(self, entity, mentor, choice):
   535     """Adjusts the possible mentors list for a proposal.
   542     """Adjusts the possible mentors list for a proposal.