More style fixes due to code reviews for Surveys.
authorLennard de Rijk <ljvderijk@gmail.com>
Wed, 15 Jul 2009 15:18:58 +0200
changeset 2659 8df08a3b17db
parent 2658 34b414a80d42
child 2660 e2654d53a643
More style fixes due to code reviews for Surveys.
app/soc/templates/soc/grading_project_survey/list/results_heading.html
app/soc/templates/soc/project_survey/list/results_heading.html
app/soc/views/helper/surveys.py
app/soc/views/models/grading_project_survey.py
app/soc/views/models/survey.py
--- a/app/soc/templates/soc/grading_project_survey/list/results_heading.html	Wed Jul 15 15:07:01 2009 +0200
+++ b/app/soc/templates/soc/grading_project_survey/list/results_heading.html	Wed Jul 15 15:18:58 2009 +0200
@@ -3,13 +3,9 @@
     <th>{{ property }}</th>
   {% endfor %}
   <th>Taken By</th>
-
   <th>Created On</th>
-
   <th>Last Modified</th>
-
   <th>Answer</th>
-
   {% if grades %}
     <th>Grade</th>
   {% endif %}
--- a/app/soc/templates/soc/project_survey/list/results_heading.html	Wed Jul 15 15:07:01 2009 +0200
+++ b/app/soc/templates/soc/project_survey/list/results_heading.html	Wed Jul 15 15:18:58 2009 +0200
@@ -3,13 +3,9 @@
     <th>{{ property }}</th>
   {% endfor %}
   <th>Taken By</th>
-
   <th>Created On</th>
-
   <th>Last Modified</th>
-
   <th>Answer</th>
-
   {% if grades %}
     <th>Grade</th>
   {% endif %}
--- a/app/soc/views/helper/surveys.py	Wed Jul 15 15:07:01 2009 +0200
+++ b/app/soc/views/helper/surveys.py	Wed Jul 15 15:18:58 2009 +0200
@@ -951,38 +951,40 @@
     return form
 
 
-def _get_csv_header(sur):
+def getCSVHeader(survey_entity):
   """CSV header helper, needs support for comment lines in CSV.
 
   Args:
-      sur: Survey entity
+      survey_entity: Survey entity
   """
 
   tpl = '# %s: %s\n'
 
   # add static properties
-  fields = ['# Melange Survey export for \n#  %s\n#\n' % sur.title]
-  fields += [tpl % (k,v) for k,v in sur.toDict().items()]
-  fields += [tpl % (f, str(getattr(sur, f))) for f in PLAIN.split()]
-  fields += [tpl % (f, str(getattr(sur, f).link_id)) for f in FIELDS.split()]
+  fields = ['# Melange Survey export for \n#  %s\n#\n' % survey_entity.title]
+  fields += [tpl % (k,v) for k,v in survey_entity.toDict().items()]
+  fields += [tpl % (f, str(getattr(survey_entity, f))) for f in PLAIN.split()]
+  fields += [tpl % (f, str(getattr(survey_entity, f).link_id))
+             for f in FIELDS.split()]
   fields.sort()
 
   # add dynamic properties
   fields += ['#\n#---\n#\n']
-  dynamic = sur.survey_content.dynamic_properties()
-  dynamic = [(prop, getattr(sur.survey_content, prop)) for prop in dynamic]
+  dynamic = survey_entity.survey_content.dynamic_properties()
+  dynamic = [(prop, getattr(survey_entity.survey_content, prop))
+             for prop in dynamic]
   fields += [tpl % (k,v) for k,v in sorted(dynamic)]
 
   # add schema
   fields += ['#\n#---\n#\n']
-  schema =  sur.survey_content.schema
+  schema =  survey_entity.survey_content.schema
   indent = '},\n#' + ' ' * 9
   fields += [tpl % ('Schema', schema.replace('},', indent)) + '#\n']
 
   return ''.join(fields).replace('\n', '\r\n')
 
 
-def _get_records(recs, props):
+def getRecords(recs, props):
   """Fetch properties from SurveyRecords for CSV export.
   """
 
@@ -1009,7 +1011,7 @@
     record_logic = survey_logic.getRecordLogic()
 
     # get header and properties
-    header = _get_csv_header(survey)
+    header = getCSVHeader(survey)
     leading = ['user', 'created', 'modified']
     properties = leading + survey.survey_content.orderedProperties()
 
@@ -1025,7 +1027,7 @@
 
     # generate results list
     recs = record_query.run()
-    recs = _get_records(recs, properties)
+    recs = getRecords(recs, properties)
 
     # write results to CSV
     output = StringIO.StringIO()
--- a/app/soc/views/models/grading_project_survey.py	Wed Jul 15 15:07:01 2009 +0200
+++ b/app/soc/views/models/grading_project_survey.py	Wed Jul 15 15:18:58 2009 +0200
@@ -73,23 +73,6 @@
 
     super(View, self).__init__(params=params)
 
-  # TODO: work on grade activation
-  def activate(self, request, **kwargs):
-    """This is a hack to support the 'Enable grades' button.
-    """
-    self.activateGrades(request)
-    redirect_path = request.path.replace('/activate/', '/edit/') + (
-        '?activate=1')
-    return http.HttpResponseRedirect(redirect_path)
-
-  def activateGrades(self, request, **kwargs):
-    """Updates SurveyRecord's grades for a given Survey.
-    """
-    survey_key_name = survey_logic.getKeyNameFromPath(request.path)
-    survey = Survey.get_by_key_name(survey_key_name)
-    survey_logic.activateGrades(survey)
-    return
-
   def _getSurveyTakeForm(self, survey, record, params, post_dict=None):
     """Returns the specific SurveyTakeForm needed for the take view.
 
--- a/app/soc/views/models/survey.py	Wed Jul 15 15:07:01 2009 +0200
+++ b/app/soc/views/models/survey.py	Wed Jul 15 15:18:58 2009 +0200
@@ -213,7 +213,7 @@
     survey_form = surveys.SurveyTakeForm(survey_content=entity.survey_content,
                                          survey_logic=self._params['logic'])
 
-    # TOOD(ljvderijk) pose question about the getFields method name and working
+    # TODO(ljvderijk) pose question about the getFields method name and working
     survey_form.getFields()
 
     context['survey_form'] = survey_form