Added getRecordLogic method to SurveyLogic.
authorLennard de Rijk <ljvderijk@gmail.com>
Tue, 30 Jun 2009 14:45:11 +0200
changeset 2462 2d5d2961f774
parent 2461 c3e3df63e683
child 2463 05af53239799
Added getRecordLogic method to SurveyLogic. This is used to retrieve the SurveyRecordLogic that belongs to a certain SurveyLogic.
app/soc/logic/models/survey.py
--- a/app/soc/logic/models/survey.py	Tue Jun 30 08:54:39 2009 +0200
+++ b/app/soc/logic/models/survey.py	Tue Jun 30 14:45:11 2009 +0200
@@ -30,6 +30,7 @@
 
 from soc.cache import sidebar
 from soc.logic.models import linkable as linkable_logic
+from soc.logic.models import survey_record as survey_record_logic
 from soc.logic.models.user import logic as user_logic
 from soc.logic.models import work
 from soc.models.program import Program
@@ -54,10 +55,16 @@
   """
 
   def __init__(self, model=Survey, base_model=Work,
-               scope_logic=linkable_logic):
+               scope_logic=linkable_logic,
+               record_logic=survey_record_logic.logic):
     """Defines the name, key_name and model for this entity.
+
+    params:
+      record_logic: SurveyRecordLogic (or subclass) instance for this Survey
     """
 
+    self.record_logic = record_logic
+
     super(Logic, self).__init__(model=model, base_model=base_model,
                                 scope_logic=scope_logic)
 
@@ -186,6 +193,15 @@
 
     return self.getForFields(fields, unique=True)
 
+<<<<<<< local
+=======
+  def getRecordLogic(self):
+    """Returns SurveyRecordLogic that belongs to this SurveyLogic.
+    """
+
+    return self.record_logic
+
+>>>>>>> other
   def getUserRole(self, user, survey, project):
     """Gets the role of a user for a project, used for SurveyRecordGroup.
 
@@ -424,12 +440,14 @@
   """
 
   def __init__(self, model=ProjectSurvey,
-               base_model=Survey, scope_logic=linkable_logic):
+               base_model=Survey, scope_logic=linkable_logic,
+               record_logic=survey_record_logic.project_logic):
     """Defines the name, key_name and model for this entity.
     """
 
     super(ProjectLogic, self).__init__(model=model, base_model=base_model,
-                                       scope_logic=scope_logic)
+                                       scope_logic=scope_logic,
+                                       record_logic=record_logic)
 
 
 class GradingProjectLogic(ProjectLogic):
@@ -437,12 +455,14 @@
   """
 
   def __init__(self, model=GradingProjectSurvey,
-               base_model=ProjectSurvey, scope_logic=linkable_logic):
+               base_model=ProjectSurvey, scope_logic=linkable_logic,
+               record_logic=survey_record_logic.grading_logic):
     """Defines the name, key_name and model for this entity.
     """
 
     super(GradingProjectLogic, self).__init__(model=model,
                                               base_model=base_model,
+<<<<<<< local
                                               scope_logic=scope_logic)
 
 class ResultsLogic(work.Logic):
@@ -456,6 +476,10 @@
 
     super(ResultsLogic, self).__init__(model=model, base_model=base_model,
                                 scope_logic=scope_logic)
+=======
+                                              scope_logic=scope_logic,
+                                              record_logic=record_logic)
+>>>>>>> other
 
   def getKeyValuesFromEntity(self, entity):
     """See base.Logic.getKeyNameValues.