app/soc/models/survey_record.py
changeset 2493 0aabd2d76606
parent 2446 0cf8f034f52d
child 2515 a3513142ae01
--- a/app/soc/models/survey_record.py	Thu Jul 02 17:08:10 2009 +0200
+++ b/app/soc/models/survey_record.py	Thu Jul 02 17:47:24 2009 +0200
@@ -39,10 +39,9 @@
   corresponding to the fields of the survey.
   """
 
-  #: Reference to the User entity which took this survey.
-  user = db.ReferenceProperty(reference_class=soc.models.user.User,
-                              required=True, collection_name="surveys_taken",
-                              verbose_name=ugettext('Created by'))
+  #: The survey for which this entity is a record.
+  survey = db.ReferenceProperty(Survey,
+                                collection_name="survey_records")
 
   #: Date when this record was created.
   created = db.DateTimeProperty(auto_now_add=True)
@@ -56,20 +55,16 @@
     Right now it gets all dynamic values, but it could also be confined to
     the SurveyContent entity linked to the survey entity.
     """
-    survey_order = self.getSurvey().survey_content.getSurveyOrder()
+    survey_order = self.survey.survey_content.getSurveyOrder()
     values = []
     for position, property in survey_order.items():
         values.insert(position, getattr(self, property, None))
     return values
 
 
-# TODO(ajaksu) think of a better way to handle the survey reference
 class SurveyRecord(BaseSurveyRecord):
 
-  #: The survey for which this entity is a record.
-  survey = db.ReferenceProperty(Survey, collection_name="survey_records")
-
-  def getSurvey(self):
-    """Returns the Survey belonging to this record.
-    """
-    return self.survey
+  #: Reference to the User entity which took this survey.
+  user = db.ReferenceProperty(reference_class=soc.models.user.User,
+                              required=True, collection_name="surveys_taken",
+                              verbose_name=ugettext('Taken by'))