app/soc/views/models/survey.py
changeset 2751 e8a98669ec8c
parent 2750 e3e3be4bed01
child 2752 fb3bed3eecd8
equal deleted inserted replaced
2750:e3e3be4bed01 2751:e8a98669ec8c
   706           survey_logic)
   706           survey_logic)
   707       allowed_to_read = True
   707       allowed_to_read = True
   708     except:
   708     except:
   709       pass
   709       pass
   710 
   710 
   711     # only show records for the retrieved survey
   711     # get the filter for the SurveyRecords
   712     fields = {'survey': entity}
   712     fields = self._getResultsViewRecordFields(entity, allowed_to_read)
   713 
       
   714     if not allowed_to_read:
       
   715       # this user is not allowed to view all the Records so only show their own
       
   716       fields['user'] = user_entity
       
   717 
       
   718     # call the hook for adjusting the SurveyRecord filter
       
   719     fields = self._getResultsViewRecordFields(fields, entity, allowed_to_read)
       
   720 
   713 
   721     list_params = params.copy()
   714     list_params = params.copy()
   722     list_params['logic'] = record_logic
   715     list_params['logic'] = record_logic
   723     list_params['list_heading'] = 'soc/survey/list/records_heading.html'
   716     list_params['list_heading'] = 'soc/survey/list/records_heading.html'
   724     list_params['list_row'] = 'soc/survey/list/records_row.html'
   717     list_params['list_row'] = 'soc/survey/list/records_row.html'
   732 
   725 
   733     contents = [record_list]
   726     contents = [record_list]
   734 
   727 
   735     return self._list(request, list_params, contents, page_name, context)
   728     return self._list(request, list_params, contents, page_name, context)
   736 
   729 
   737   def _getResultsViewRecordFields(self, fields, survey, allowed_to_read):
   730   def _getResultsViewRecordFields(self, survey, allowed_to_read):
   738     """Hook for adjusting the Results View filter for SurveyRecords.
   731     """Retrieves the Results View filter for SurveyRecords.
   739 
   732 
   740     Args:
   733     Args:
   741       fields: filter dictionary to adjust
       
   742       survey: Survey instance for which the Records need to be shown
   734       survey: Survey instance for which the Records need to be shown
   743       allowed_to_read: specifies if the current User has read access
   735       allowed_to_read: specifies if the current User has read access
   744 
   736 
   745     Returns:
   737     Returns:
   746       Returns the dictionary containing the fields to filter on
   738       Returns the dictionary containing the fields to filter on
   747     """
   739     """
       
   740 
       
   741     # only show records for the retrieved survey
       
   742     fields = {'survey': survey}
       
   743 
       
   744     if not allowed_to_read:
       
   745       # this user is not allowed to view all the Records so only show their own
       
   746       fields['user'] = user_logic.getForCurrentAccount()
       
   747 
   748     return fields
   748     return fields
   749 
   749 
   750   @decorators.merge_params
   750   @decorators.merge_params
   751   @decorators.check_access
   751   @decorators.check_access
   752   def viewRecord(self, request, access_type, page_name=None,
   752   def viewRecord(self, request, access_type, page_name=None,