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
--- 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 @@
<td>
<input style="font-weight: bold" type="submit" value="Submit"/></span>
</td>
- {% if mentor %}
+ {% if add_me_as_mentor %}
<td>
- <input style="font-weight: bold" type="button" value="Want to be Possible Mentor"
+ <input style="font-weight: bold" type="button" value="I am willing to mentor this student"
onclick="location.href='?mentor=1'"/>
</td>
- <td>
- <input style="font-weight: bold" type="button" value="Do not want to be Possible Mentor"
- onclick="location.href='?mentor=0'"/>
- </td>
+ {% else %}
+ {% if remove_me_as_mentor %}
+ <td>
+ <input style="font-weight: bold" type="button" value="I am no longer willing to mentor this student"
+ onclick="location.href='?mentor=0'"/>
+ </td>
+ {% endif %}
{% endif %}
</table>
</form>
--- 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)