Added getSurveyForContent method to SurveyLogic.
This method returns a Survey for a given content. The backreferenceproperty will not work because of inheritance.
--- 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.