Add Organization reference property to ProjectSurveyRecord.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Sat, 11 Jul 2009 19:54:23 +0200
changeset 2591 6c57c482f913
parent 2590 f0d0c9e7b2d4
child 2592 040359ccd20b
Add Organization reference property to ProjectSurveyRecord. Also update ProjectSurvey view _takePost method to set this property everytime survey is taken.
app/soc/models/project_survey_record.py
app/soc/views/models/project_survey.py
--- a/app/soc/models/project_survey_record.py	Sat Jul 11 19:37:26 2009 +0200
+++ b/app/soc/models/project_survey_record.py	Sat Jul 11 19:54:23 2009 +0200
@@ -25,6 +25,7 @@
 
 from google.appengine.ext import db
 
+from soc.models.organization import Organization
 from soc.models.survey_record import SurveyRecord
 from soc.models.project_survey import ProjectSurvey
 import soc.models.student_project
@@ -39,3 +40,10 @@
   project = db.ReferenceProperty(
       reference_class=soc.models.student_project.StudentProject,
       required=True, collection_name="survey_records")
+  
+  #: A many:1 relationship associating ProjectSurveyRecords 
+  #: with specific Organization. The back-reference in the 
+  #: Organization model is a Query named 'survey_records'.
+  org = db.ReferenceProperty(
+      reference_class=Organization, 
+      required=False, collection_name='survey_records')
--- a/app/soc/views/models/project_survey.py	Sat Jul 11 19:37:26 2009 +0200
+++ b/app/soc/views/models/project_survey.py	Sat Jul 11 19:54:23 2009 +0200
@@ -147,7 +147,7 @@
     project_entity = student_project_logic.getFromKeyName(get_dict['project'])
 
     # update the properties that will be stored with the referenced project
-    properties.update(project=project_entity)
+    properties.update(project=project_entity, org=project_entity.scope)
 
   def _constructFilterForProjectSelection(self, survey, params):
     """Returns the filter needed for the Project selection view.