X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fmodels%2Fplcorebase.py;fp=planetstack%2Fcore%2Fmodels%2Fplcorebase.py;h=dee8a87e1d575d8f2443195620efc4a8b708df8f;hb=9ec6bce113684daca0e658b31b5ab1ee29405eb8;hp=95959f4e064118d0dda496a67e2a371847979178;hpb=5ae5619a90da860a18fbcf1ed7a709aec1f9fd4f;p=plstackapi.git diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py index 95959f4..dee8a87 100644 --- a/planetstack/core/models/plcorebase.py +++ b/planetstack/core/models/plcorebase.py @@ -83,6 +83,20 @@ class DiffModelMixIn: def get_field_diff(self, field_name): return self.diff.get(field_name, None) + #classmethod + def getValidators(cls): + """ primarily for REST API, return a dictionary of field names mapped + to lists of the type of validations that need to be applied to + those fields. + """ + validators = {} + for field in cls._meta.fields: + l = [] + if field.blank==False: + l.append("notBlank") + validators[field.name] = l + return validators + class PlCoreBase(models.Model): # , DiffModelMixIn): objects = PlCoreBaseManager() deleted_objects = PlCoreBaseDeletionManager() @@ -118,6 +132,21 @@ class PlCoreBase(models.Model): # , DiffModelMixIn): def get_field_diff(self, field_name): return self.diff.get(field_name, None) + + #classmethod + def getValidators(cls): + """ primarily for REST API, return a dictionary of field names mapped + to lists of the type of validations that need to be applied to + those fields. + """ + validators = {} + for field in cls._meta.fields: + l = [] + if field.blank==False: + l.append("notBlank") + validators[field.name] = l + return validators + # ---- end copy stuff from DiffModelMixin ---- # default values for created and updated are only there to keep evolution @@ -206,19 +235,6 @@ class PlCoreBase(models.Model): # , DiffModelMixIn): def is_ephemeral(cls): return cls in ephemeral_models - def getValidators(self): - """ primarily for REST API, return a dictionary of field names mapped - to lists of the type of validations that need to be applied to - those fields. - """ - validators = {} - for field in self._meta.fields: - l = [] - if field.blank==False: - l.append("notBlank") - validators[field.name] = l - return validators -