ViewResults for Surveys is now showing all SurveyRecords.
authorLennard de Rijk <ljvderijk@gmail.com>
Tue, 04 Aug 2009 17:00:46 +0200
changeset 2727 19e985f09de8
parent 2726 0d9e4b0a9d3c
child 2728 e6e8a5530589
ViewResults for Surveys is now showing all SurveyRecords. The redirect will redirect the user to the viewing of a single SurveyRecord.
app/soc/views/models/survey.py
--- a/app/soc/views/models/survey.py	Tue Aug 04 16:57:27 2009 +0200
+++ b/app/soc/views/models/survey.py	Tue Aug 04 17:00:46 2009 +0200
@@ -672,19 +672,19 @@
   @decorators.check_access
   def viewResults(self, request, access_type, page_name=None,
                   params=None, **kwargs):
-    """View for SurveyRecords.
+    """View that will list the survey records.
 
     For params see base.View.public().
     """
 
-    # TODO(ljvderijk) finish this method
-    return http.HttpResponse("Work In Progress")
-
     # TODO If read access then show all records, else show only mine +
     # hook for subclasses. On both possibilities.
 
+    survey_logic = params['logic']
+    record_logic = survey_logic.getRecordLogic()
+
     try:
-      entity = params['logic'].getFromKeyFieldsOr404(kwargs)
+      entity = survey_logic.getFromKeyFieldsOr404(kwargs)
     except out_of_band.Error, error:
       return responses.errorResponse(
           error, request, template=params['error_public'])
@@ -695,22 +695,19 @@
     context['page_name'] = "%s titled '%s'" % (page_name, entity.title)
     context['entity'] = entity
 
-    results_logic = params['logic'].getRecordLogic()
-
     # only show truncated preview of first answer
     context['first_question'] = entity.survey_content.orderedProperties()[0]
 
-    context['record_redirect'] = redirects.getSurveyRecordRedirect(
-        entity, params)
-
     filter = {'survey': entity}
 
     list_params = params.copy()
+    list_params['logic'] = record_logic
+    list_params['list_heading'] = 'soc/survey/list/records_heading.html'
+    list_params['list_row'] = 'soc/survey/list/records_row.html'
     list_params['list_description'] = \
       'List of %(name_plural)s.' % list_params
-    list_params['logic'] = results_logic
-    list_params['list_heading'] = 'soc/survey/list/results_heading.html'
-    list_params['list_row'] = 'soc/survey/list/results_row.html'
+    list_params['list_action'] = (redirects.getViewSurveyRecordRedirect,
+                                  list_params)
 
     record_list = lists.getListContent(request, list_params, filter, idx=0)