# HG changeset patch # User Lennard de Rijk # Date 1248772842 -7200 # Node ID 08ec7ca16dce785acffe9aabfd396ba1055beb5d # Parent 8ea17736a10d96c2836ca287a2157df4ae46dc7b Added hasAtLeastOneRecord method to Survey Logic. diff -r 8ea17736a10d -r 08ec7ca16dce app/soc/logic/models/survey.py --- a/app/soc/logic/models/survey.py Mon Jul 27 15:03:20 2009 +0200 +++ b/app/soc/logic/models/survey.py Tue Jul 28 11:20:42 2009 +0200 @@ -346,6 +346,18 @@ # return the scope return entity.scope + def hasAtLeastOneRecord(self, survey_entity): + """Returns True iff the given Survey has at least one SurveyRecord. + + Args: + survey_entity: a Survey instance + """ + + fields = {'survey': survey_entity} + + record_logic = self.getRecordLogic() + return record_logic.getQueryForFields(fields).count(1) > 0 + def _onCreate(self, entity): """Set the scope of the survey. """