# HG changeset patch # User Lennard de Rijk # Date 1246344656 -7200 # Node ID b8b0c631bcfed953ee1dec56dffec3209771cdad # Parent accd8ba94b4451bc1b6a65e3695e8c33e756abf3 Added getSurveyForContent method to SurveyLogic. This method returns a Survey for a given content. The backreferenceproperty will not work because of inheritance. diff -r accd8ba94b44 -r b8b0c631bcfe app/soc/logic/models/survey.py --- a/app/soc/logic/models/survey.py Tue Jun 30 08:49:34 2009 +0200 +++ b/app/soc/logic/models/survey.py Tue Jun 30 08:50:56 2009 +0200 @@ -172,6 +172,20 @@ return survey_record_group + def getSurveyForContent(self, survey_content): + """Returns the Survey belonging to the given SurveyContent. + + params: + survey_content: the SurveyContent to retrieve the Survey for. + + returns: + Survey or subclass if possible else None. + """ + + fields = {'survey_content': survey_content} + + return self.getForFields(fields, unique=True) + def getUserRole(self, user, survey, project): """Gets the role of a user for a project, used for SurveyRecordGroup.