Show all Co-Mentors on the Student Project public page.
authorLennard de Rijk <ljvderijk@gmail.com>
Sat, 25 Apr 2009 20:52:03 +0200
changeset 2280 157f6b8de010
parent 2279 e31414fd3b2a
child 2281 a702d92a57a6
Show all Co-Mentors on the Student Project public page. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/templates/soc/student_project/public.html
app/soc/views/models/student_project.py
--- a/app/soc/templates/soc/student_project/public.html	Sat Apr 25 20:50:48 2009 +0200
+++ b/app/soc/templates/soc/student_project/public.html	Sat Apr 25 20:52:03 2009 +0200
@@ -40,6 +40,9 @@
  <table>
   {% readonly_field_as_table_row "Student Name" entity.student.name %}
   {% readonly_field_as_table_row "Mentor Name" entity.mentor.name %}
+  {% if additional_mentors %}
+    {% readonly_field_as_table_row "Co-Mentors" additional_mentors %}
+  {% endif %}
   {% readonly_field_as_table_row entity.fields.title.label entity.title %}
   {% readonly_field_as_table_row entity.fields.abstract.label entity.abstract %}
   {% readonly_safe_field_as_table_row entity.fields.public_info.label entity.public_info %}
--- a/app/soc/views/models/student_project.py	Sat Apr 25 20:50:48 2009 +0200
+++ b/app/soc/views/models/student_project.py	Sat Apr 25 20:52:03 2009 +0200
@@ -200,6 +200,26 @@
               'status': 'active'}
     fields['mentor'] = mentor_logic.logic.getForFields(filter, unique=True)
 
+  def _public(self, request, entity, context):
+    """Adds the names of all additional mentors to the context.
+
+    For params see base.View._public()
+    """
+
+    additional_mentors = entity.additional_mentors
+
+    if not additional_mentors:
+      context['additional_mentors'] = []
+    else:
+      mentor_names = []
+
+      for mentor_key in additional_mentors:
+        additional_mentor = mentor_logic.logic.getFromKeyName(
+            mentor_key.id_or_name())
+        mentor_names.append(additional_mentor.name())
+
+      context['additional_mentors'] = ', '.join(mentor_names)
+
   @decorators.merge_params
   @decorators.check_access
   def manage(self, request, access_type,