Added project title and student name to the ProjectSurvey take page.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 09 Aug 2009 13:42:31 -0700
changeset 2740 4b8aa5b9cb23
parent 2739 22f41aafcedc
child 2741 107bec037dda
Added project title and student name to the ProjectSurvey take page. This required some reodering of the Survey take template and also a renamed setH elpAndStatus to _setSurveyTakeContext.
app/soc/templates/soc/project_survey/take.html
app/soc/templates/soc/survey/take.html
app/soc/views/models/project_survey.py
app/soc/views/models/survey.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/project_survey/take.html	Sun Aug 09 13:42:31 2009 -0700
@@ -0,0 +1,18 @@
+{% extends "soc/survey/take.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% block help_text %}
+{{ block.super }}
+This survey is being taken for a project titled "{{ project_entity.title }}" by {{ project_entity.student.name }}.
+{% endblock help_text %}
--- a/app/soc/templates/soc/survey/take.html	Sun Aug 09 13:03:47 2009 -0700
+++ b/app/soc/templates/soc/survey/take.html	Sun Aug 09 13:42:31 2009 -0700
@@ -12,6 +12,7 @@
 See the License for the specific language governing permissions and
 limitations under the License.
 {% endcomment %}
+{% load forms_helpers %}
 
 {% block scripts %}
 {{ block.super }}
@@ -27,46 +28,50 @@
 {% block body %}
 <div id="created">Last modified on {{ entity.modified }} by {{ entity.modified_by.name }}</div>
 
-{% if survey_form %}
-
-  {% load forms_helpers %}
-
-  {{ help_text }}
+<div id="help_text">
+  {% block help_text %}
+    {{ help_text }}
+  {% endblock help_text %}
+</div>
 
-  {% if entity.content %}
-    <div id="survey_description">
-      {{ entity.content|safe }}
-    </div>
-  {% endif %}
+{% block survey_description %}
+{% if entity.content %}
+  <div id="survey_description">
+    {{ entity.content|safe }}
+  </div>
+{% endif %}
+{% endblock survey_description %}
 
-  {% if form_action %}
-    <form method="post" action="{{ form_action }}">
-  {% else %}
-    <form method="post">
-  {% endif %}
-    <div style="width:100%;">
-      <div class="{{ status }}" id="survey_widget">
-        <table>
-          {% block form_table %}
-            {% as_twoline_table survey_form %}
-          {% endblock %}
-        </table>
-      </div> {# end survey_widget #}
-    </div>
+{% block survey_form %}
+{% if form_action %}
+  <form method="post" action="{{ form_action }}">
+{% else %}
+  <form method="post">
+{% endif %}
+  <div style="width:100%;">
+    <div class="{{ status }}" id="survey_widget">
+      <table>
+        {% block form_table %}
+          {% as_twoline_table survey_form %}
+        {% endblock %}
+      </table>
+    </div> {# end survey_widget #}
+  </div>
 
-<br><br>
-    <div>
-      <table>
-        <tbody>
-          <tr>
-            <td>
-              <input type="submit" value="Submit" style="font-weight: bold;">
-            </td>
-          </tr>
-        </tbody>
-      </table>
-    </div>
-  </form>
-{% endif %}
+  <br /><br />
 
-{% endblock %}
+  <div>
+    <table>
+      <tbody>
+        <tr>
+          <td>
+            <input type="submit" value="Submit" style="font-weight: bold;">
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </div>
+</form>
+{% endblock survey_form %}
+
+{% endblock body %}
--- a/app/soc/views/models/project_survey.py	Sun Aug 09 13:03:47 2009 -0700
+++ b/app/soc/views/models/project_survey.py	Sun Aug 09 13:42:31 2009 -0700
@@ -77,9 +77,12 @@
           'soc.views.models.%(module_name)s.send_reminder',
          'Send Reminder for %(name)s')]
 
+    new_params['take_template'] = 'soc/project_survey/take.html'
+
     # used for sending reminders
     new_params['survey_type'] = 'project'
     new_params['reminder_template'] = 'soc/project_survey/reminder.html'
+
     new_params['manage_student_project_heading'] = \
         'soc/project_survey/list/heading_manage_student_project.html'
     new_params['manage_student_project_row'] = \
@@ -168,6 +171,31 @@
     # update the properties that will be stored with the referenced project
     properties.update(project=project_entity, org=project_entity.scope)
 
+  def _setSurveyTakeContext(self, request, params, context, survey,
+                            survey_record):
+    """Sets the context for the ProjectSurvey take page.
+
+    This includes setting the help_text, status and project_entity.
+
+    Args:
+        request: HTTP request object
+        params: the params for the current View
+        context: the context for the view to update
+        survey: a Survey entity
+        survey_record: a SurveyRecordEntity
+    """
+
+    from soc.logic.models.student_project import logic as student_project_logic
+
+    # call super first to set the other context items
+    super(View, self)._setSurveyTakeContext(request, params, context, survey,
+                                            survey_record)
+
+    # retrieve the project using the key name in the GET param
+    get_dict = request.GET
+    context['project_entity'] = student_project_logic.getFromKeyName(
+        get_dict['project'])
+
   def _constructFilterForProjectSelection(self, survey, params):
     """Returns the filter needed for the Project selection view.
 
--- a/app/soc/views/models/survey.py	Sun Aug 09 13:03:47 2009 -0700
+++ b/app/soc/views/models/survey.py	Sun Aug 09 13:42:31 2009 -0700
@@ -506,7 +506,7 @@
 
     # fill context with the survey_form and additional information
     context['survey_form'] = survey_form
-    self.setHelpAndStatus(context, entity, survey_record)
+    self._setSurveyTakeContext(request, params, context, entity, survey_record)
 
     if request.POST:
       return self.takePost(request, template, context, params, survey_form,
@@ -642,14 +642,16 @@
     """
     pass
 
-
-  def setHelpAndStatus(self, context, survey, survey_record):
-    """Get help_text and status for template use.
+  def _setSurveyTakeContext(self, request, params, context, survey,
+                            survey_record):
+    """Sets the help_text and status for take template use.
 
     Args:
+        request: HTTP request object
+        params: the params for the current View
         context: the context for the view to update
         survey: a Survey entity
-        survey_record: a SurveyRecordEntity
+        survey_record: a SurveyRecordEntity iff exists
     """
 
     if not survey.survey_end: