# HG changeset patch # User Lennard de Rijk # Date 1236204686 0 # Node ID cdb7e55816944228eafcb2a4c24ccedb6dda3a9d # Parent 9d623ebfff0d510600cf08a49347f1028a2cc458 Mentor buttons only show up depending on if you are already on the possible mentors list. Also made the textual changes stated in a comment on r2250. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 9d623ebfff0d -r cdb7e5581694 app/soc/templates/soc/student_proposal/review.html --- a/app/soc/templates/soc/student_proposal/review.html Wed Mar 04 21:27:11 2009 +0000 +++ b/app/soc/templates/soc/student_proposal/review.html Wed Mar 04 22:11:26 2009 +0000 @@ -51,15 +51,18 @@ - {% if mentor %} + {% if add_me_as_mentor %} - - - - + {% else %} + {% if remove_me_as_mentor %} + + + + {% endif %} {% endif %} diff -r 9d623ebfff0d -r cdb7e5581694 app/soc/views/models/student_proposal.py --- a/app/soc/views/models/student_proposal.py Wed Mar 04 21:27:11 2009 +0000 +++ b/app/soc/views/models/student_proposal.py Wed Mar 04 22:11:26 2009 +0000 @@ -424,20 +424,6 @@ if mentor_entity and choice: self._adjustPossibleMentors(entity, mentor_entity, choice) - # set the possible mentors in the context - possible_mentors = entity.possible_mentors - - if not possible_mentors: - context['possible_mentors'] = "None" - else: - mentor_names = [] - - for mentor_key in possible_mentors: - mentor = mentor_logic.logic.getFromKeyName(mentor_key.name()) - mentor_names.append(mentor.name()) - - context['possible_mentors'] = ', '.join(mentor_names) - # decide which form to use if org_admin_entity: form = params['admin_review_form'] @@ -527,7 +513,28 @@ context['form'] = form(initial) template = params['review_template'] - context['mentor'] = mentor + + # set the possible mentors in the context + possible_mentors = entity.possible_mentors + + if not possible_mentors: + context['possible_mentors'] = "None" + else: + mentor_names = [] + + for mentor_key in possible_mentors: + mentor = mentor_logic.logic.getFromKeyName(mentor_key.name()) + mentor_names.append(mentor.name()) + + context['possible_mentors'] = ', '.join(mentor_names) + + if mentor: + if mentor.key() in possible_mentors: + # show "No longer willing to mentor" + context['remove_me_as_mentor'] = True + else: + # show "I am willing to mentor" + context['add_me_as_mentor'] = True return responses.respond(request, template, context=context)