app/soc/logic/models/survey.py
changeset 2462 2d5d2961f774
parent 2460 b8b0c631bcfe
child 2466 70854ec7909d
equal deleted inserted replaced
2461:c3e3df63e683 2462:2d5d2961f774
    28 
    28 
    29 from google.appengine.ext import db
    29 from google.appengine.ext import db
    30 
    30 
    31 from soc.cache import sidebar
    31 from soc.cache import sidebar
    32 from soc.logic.models import linkable as linkable_logic
    32 from soc.logic.models import linkable as linkable_logic
       
    33 from soc.logic.models import survey_record as survey_record_logic
    33 from soc.logic.models.user import logic as user_logic
    34 from soc.logic.models.user import logic as user_logic
    34 from soc.logic.models import work
    35 from soc.logic.models import work
    35 from soc.models.program import Program
    36 from soc.models.program import Program
    36 from soc.models import student_project
    37 from soc.models import student_project
    37 from soc.models.survey import Survey
    38 from soc.models.survey import Survey
    52 class Logic(work.Logic):
    53 class Logic(work.Logic):
    53   """Logic methods for the Survey model.
    54   """Logic methods for the Survey model.
    54   """
    55   """
    55 
    56 
    56   def __init__(self, model=Survey, base_model=Work,
    57   def __init__(self, model=Survey, base_model=Work,
    57                scope_logic=linkable_logic):
    58                scope_logic=linkable_logic,
       
    59                record_logic=survey_record_logic.logic):
    58     """Defines the name, key_name and model for this entity.
    60     """Defines the name, key_name and model for this entity.
    59     """
    61 
       
    62     params:
       
    63       record_logic: SurveyRecordLogic (or subclass) instance for this Survey
       
    64     """
       
    65 
       
    66     self.record_logic = record_logic
    60 
    67 
    61     super(Logic, self).__init__(model=model, base_model=base_model,
    68     super(Logic, self).__init__(model=model, base_model=base_model,
    62                                 scope_logic=scope_logic)
    69                                 scope_logic=scope_logic)
    63 
    70 
    64   def createSurvey(self, survey_fields, schema, survey_content=False):
    71   def createSurvey(self, survey_fields, schema, survey_content=False):
   184 
   191 
   185     fields = {'survey_content': survey_content}
   192     fields = {'survey_content': survey_content}
   186 
   193 
   187     return self.getForFields(fields, unique=True)
   194     return self.getForFields(fields, unique=True)
   188 
   195 
       
   196 <<<<<<< local
       
   197 =======
       
   198   def getRecordLogic(self):
       
   199     """Returns SurveyRecordLogic that belongs to this SurveyLogic.
       
   200     """
       
   201 
       
   202     return self.record_logic
       
   203 
       
   204 >>>>>>> other
   189   def getUserRole(self, user, survey, project):
   205   def getUserRole(self, user, survey, project):
   190     """Gets the role of a user for a project, used for SurveyRecordGroup.
   206     """Gets the role of a user for a project, used for SurveyRecordGroup.
   191 
   207 
   192     params:
   208     params:
   193       user: user taking survey
   209       user: user taking survey
   422 class ProjectLogic(Logic):
   438 class ProjectLogic(Logic):
   423   """Logic class for ProjectSurvey.
   439   """Logic class for ProjectSurvey.
   424   """
   440   """
   425 
   441 
   426   def __init__(self, model=ProjectSurvey,
   442   def __init__(self, model=ProjectSurvey,
   427                base_model=Survey, scope_logic=linkable_logic):
   443                base_model=Survey, scope_logic=linkable_logic,
       
   444                record_logic=survey_record_logic.project_logic):
   428     """Defines the name, key_name and model for this entity.
   445     """Defines the name, key_name and model for this entity.
   429     """
   446     """
   430 
   447 
   431     super(ProjectLogic, self).__init__(model=model, base_model=base_model,
   448     super(ProjectLogic, self).__init__(model=model, base_model=base_model,
   432                                        scope_logic=scope_logic)
   449                                        scope_logic=scope_logic,
       
   450                                        record_logic=record_logic)
   433 
   451 
   434 
   452 
   435 class GradingProjectLogic(ProjectLogic):
   453 class GradingProjectLogic(ProjectLogic):
   436   """Logic class for GradingProjectSurvey
   454   """Logic class for GradingProjectSurvey
   437   """
   455   """
   438 
   456 
   439   def __init__(self, model=GradingProjectSurvey,
   457   def __init__(self, model=GradingProjectSurvey,
   440                base_model=ProjectSurvey, scope_logic=linkable_logic):
   458                base_model=ProjectSurvey, scope_logic=linkable_logic,
       
   459                record_logic=survey_record_logic.grading_logic):
   441     """Defines the name, key_name and model for this entity.
   460     """Defines the name, key_name and model for this entity.
   442     """
   461     """
   443 
   462 
   444     super(GradingProjectLogic, self).__init__(model=model,
   463     super(GradingProjectLogic, self).__init__(model=model,
   445                                               base_model=base_model,
   464                                               base_model=base_model,
       
   465 <<<<<<< local
   446                                               scope_logic=scope_logic)
   466                                               scope_logic=scope_logic)
   447 
   467 
   448 class ResultsLogic(work.Logic):
   468 class ResultsLogic(work.Logic):
   449   """Logic methods for the Survey model
   469   """Logic methods for the Survey model
   450   """
   470   """
   454     """Defines the name, key_name and model for this entity.
   474     """Defines the name, key_name and model for this entity.
   455     """
   475     """
   456 
   476 
   457     super(ResultsLogic, self).__init__(model=model, base_model=base_model,
   477     super(ResultsLogic, self).__init__(model=model, base_model=base_model,
   458                                 scope_logic=scope_logic)
   478                                 scope_logic=scope_logic)
       
   479 =======
       
   480                                               scope_logic=scope_logic,
       
   481                                               record_logic=record_logic)
       
   482 >>>>>>> other
   459 
   483 
   460   def getKeyValuesFromEntity(self, entity):
   484   def getKeyValuesFromEntity(self, entity):
   461     """See base.Logic.getKeyNameValues.
   485     """See base.Logic.getKeyNameValues.
   462     """
   486     """
   463 
   487