X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fmodels%2Fplcorebase.py;h=95959f4e064118d0dda496a67e2a371847979178;hb=3f130078930766267756b68e971e0a295d351740;hp=782737ce4d9041294c83778fb499d61e80f3d870;hpb=72d1abe88a3ff715fc9dd6061cfcb1432e2385d3;p=plstackapi.git diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py index 782737c..95959f4 100644 --- a/planetstack/core/models/plcorebase.py +++ b/planetstack/core/models/plcorebase.py @@ -7,6 +7,7 @@ from django.forms.models import model_to_dict from django.utils import timezone from django.core.exceptions import PermissionDenied import model_policy +from model_autodeletion import ephemeral_models try: # This is a no-op if observer_disabled is set to 1 in the config file @@ -203,7 +204,22 @@ class PlCoreBase(models.Model): # , DiffModelMixIn): @classmethod def is_ephemeral(cls): - return False + 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 + +