From 9ec6bce113684daca0e658b31b5ab1ee29405eb8 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 25 Nov 2014 11:35:19 -0800 Subject: [PATCH] validators for xoslib --- planetstack/core/models/plcorebase.py | 42 +++++--- .../xoslib/static/js/xoslib/xos-validators.js | 102 +++++++++--------- .../core/xoslib/tools/make_validators.py | 12 +-- 3 files changed, 83 insertions(+), 73 deletions(-) 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 - diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-validators.js b/planetstack/core/xoslib/static/js/xoslib/xos-validators.js index 0c04274..8865ce6 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-validators.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-validators.js @@ -1,52 +1,52 @@ -function xos_get_defaults() { - this.account = {"updated": null, "created": null, "deleted": false, "site": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.charge = {"updated": null, "slice": null, "created": null, "deleted": false, "object": null, "account": null, "date": null, "amount": 0.0, "state": "pending", "invoice": null, "coreHours": 0.0, "backend_status": "Provisioning in progress", "kind": "besteffort", "enacted": null}; - this.dashboardView = {"updated": null, "name": "", "created": null, "deleted": false, "url": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.deployment = {"accessControl": "allow all", "updated": null, "admin_user": null, "name": "", "created": null, "deleted": false, "availability_zone": null, "backend_type": null, "auth_url": null, "admin_password": null, "backend_status": "Provisioning in progress", "admin_tenant": null, "enacted": null}; - this.deploymentPrivilege = {"updated": null, "created": null, "deleted": false, "role": null, "user": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.deploymentRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.flavor = {"updated": null, "description": null, "created": null, "deleted": false, "enacted": null, "default": false, "flavor": "", "backend_status": "Provisioning in progress", "order": 0, "name": ""}; - this.image = {"updated": null, "name": "", "created": null, "deleted": false, "container_format": "", "disk_format": "", "path": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.imageDeployments = {"updated": null, "created": null, "deleted": false, "image": null, "deployment": null, "backend_status": "Provisioning in progress", "glance_image_id": null, "enacted": null}; - this.invoice = {"updated": null, "created": null, "deleted": false, "account": null, "date": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.network = {"controllerParameters": null, "subnet": "", "updated": null, "name": "", "created": null, "subnet_id": null, "network_id": null, "labels": null, "deleted": false, "guaranteedBandwidth": 0, "controllerUrl": null, "topologyParameters": null, "router_id": null, "template": null, "owner": null, "backend_status": "Provisioning in progress", "ports": null, "permitAllSlices": false, "enacted": null}; - this.networkDeployments = {"router_id": null, "subnet": "", "updated": null, "network": null, "created": null, "deleted": false, "subnet_id": null, "deployment": null, "backend_status": "Provisioning in progress", "net_id": null, "enacted": null}; - this.networkParameter = {"updated": null, "created": null, "deleted": false, "object_id": null, "value": "", "content_type": null, "backend_status": "Provisioning in progress", "parameter": null, "enacted": null}; - this.networkParameterType = {"updated": null, "description": "", "created": null, "deleted": false, "enacted": null, "backend_status": "Provisioning in progress", "name": ""}; - this.networkSlice = {"updated": null, "slice": null, "network": null, "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null}; - this.networkSliver = {"updated": null, "network": null, "created": null, "deleted": false, "ip": null, "enacted": null, "backend_status": "Provisioning in progress", "port_id": null, "sliver": null}; - this.networkTemplate = {"controllerKind": null, "updated": null, "backend_status": "Provisioning in progress", "description": null, "created": null, "deleted": false, "sharedNetworkName": null, "guaranteedBandwidth": 0, "visibility": "private", "enacted": null, "translation": "none", "sharedNetworkId": null, "topologyKind": "BigSwitch", "name": ""}; - this.node = {"updated": null, "name": "", "created": null, "deleted": false, "site": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.payment = {"updated": null, "created": null, "deleted": false, "account": null, "amount": 0.0, "date": "2014-11-25T19:20:14.905Z", "backend_status": "Provisioning in progress", "enacted": null}; - this.planetStack = {"updated": null, "description": "PlanetStack", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null}; - this.planetStackPrivilege = {"updated": null, "created": null, "deleted": false, "role": null, "user": null, "backend_status": "Provisioning in progress", "planetstack": 1, "enacted": null}; - this.planetStackRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.project = {"updated": null, "name": "", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null}; - this.reservation = {"updated": null, "slice": null, "created": null, "deleted": false, "startTime": null, "duration": 1, "backend_status": "Provisioning in progress", "enacted": null}; - this.reservedResource = {"updated": null, "reservationSet": null, "created": null, "deleted": false, "resource": null, "enacted": null, "backend_status": "Provisioning in progress", "quantity": 1, "sliver": null}; - this.role = {"updated": null, "description": "", "created": null, "deleted": false, "role": null, "content_type": null, "backend_status": "Provisioning in progress", "role_type": "", "enacted": null}; - this.router = {"updated": null, "name": "", "created": null, "deleted": false, "owner": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.service = {"updated": null, "description": null, "created": null, "deleted": false, "enabled": true, "versionNumber": "", "published": true, "enacted": null, "backend_status": "Provisioning in progress", "name": ""}; - this.serviceAttribute = {"updated": null, "name": "", "service": null, "created": null, "deleted": false, "value": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.serviceClass = {"updated": null, "membershipFee": 0, "membershipFeeMonths": 12, "created": null, "deleted": false, "description": "", "commitment": 365, "enacted": null, "backend_status": "Provisioning in progress", "upgradeRequiresApproval": false, "name": ""}; - this.serviceResource = {"updated": null, "name": "", "bucketMaxSize": 0, "created": null, "deleted": false, "serviceClass": null, "maxUnitsDeployment": 1, "maxDuration": 1, "maxUnitsNode": 1, "cost": 0, "enacted": null, "backend_status": "Provisioning in progress", "bucketInRate": 0, "calendarReservable": true}; - this.site = {"updated": null, "name": "", "created": null, "deleted": false, "enabled": true, "longitude": null, "site_url": null, "login_base": "", "location": "0,0", "latitude": null, "is_public": true, "backend_status": "Provisioning in progress", "abbreviated_name": "", "enacted": null}; - this.siteCredential = {"updated": null, "name": "", "created": null, "deleted": false, "site": null, "key_id": "", "enacted": null, "backend_status": "Provisioning in progress", "enc_value": ""}; - this.siteDeployments = {"updated": null, "created": null, "deleted": false, "tenant_id": null, "site": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.sitePrivilege = {"updated": null, "created": null, "deleted": false, "site": null, "role": null, "user": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.siteRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.slice = {"updated": null, "imagePreference": "Ubuntu 12.04 LTS", "name": "", "service": null, "created": null, "deleted": false, "slice_url": "", "serviceClass": 1, "enabled": true, "site": null, "omf_friendly": false, "network": "Private Only", "max_slivers": 10, "mountDataSets": "GenBank", "enacted": null, "backend_status": "Provisioning in progress", "creator": null, "description": ""}; - this.sliceCredential = {"updated": null, "slice": null, "name": "", "created": null, "deleted": false, "key_id": "", "enacted": null, "backend_status": "Provisioning in progress", "enc_value": ""}; - this.sliceDeployments = {"router_id": null, "updated": null, "slice": null, "network_id": null, "created": null, "deleted": false, "tenant_id": null, "subnet_id": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.slicePrivilege = {"updated": null, "slice": null, "created": null, "deleted": false, "role": null, "user": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.sliceRole = {"updated": null, "created": null, "deleted": false, "role": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.sliceTag = {"updated": null, "slice": null, "name": "", "created": null, "deleted": false, "value": "", "backend_status": "Provisioning in progress", "enacted": null}; - this.sliver = {"node": null, "instance_id": null, "updated": null, "slice": null, "deploymentNetwork": null, "name": "", "created": null, "deleted": false, "ip": null, "image": null, "creator": null, "numberCores": 0, "instance_name": null, "userData": null, "backend_status": "Provisioning in progress", "flavor": 2, "enacted": null}; - this.tag = {"updated": null, "name": "", "service": null, "created": null, "deleted": false, "value": "", "object_id": null, "content_type": null, "backend_status": "Provisioning in progress", "enacted": null}; - this.usableObject = {"updated": null, "name": "", "created": null, "deleted": false, "backend_status": "Provisioning in progress", "enacted": null}; - this.user = {"username": "Something", "public_key": null, "updated": null, "password": "", "is_readonly": false, "firstname": "", "user_url": null, "deleted": false, "lastname": "", "created": null, "is_active": true, "site": null, "phone": null, "is_staff": true, "last_login": "2014-11-25T19:20:14.986Z", "is_admin": true, "timezone": "America/New_York", "backend_status": "Provisioning in progress", "email": "", "enacted": null}; - this.userCredential = {"updated": null, "name": "", "created": null, "deleted": false, "user": null, "key_id": "", "enacted": null, "backend_status": "Provisioning in progress", "enc_value": ""}; - this.userDashboardView = {"updated": null, "created": null, "deleted": false, "dashboardView": null, "user": null, "backend_status": "Provisioning in progress", "order": 0, "enacted": null}; - this.userDeployments = {"updated": null, "created": null, "deleted": false, "kuser_id": null, "user": null, "deployment": null, "backend_status": "Provisioning in progress", "enacted": null}; +function xos_get_validators() { + this.account = {"updated": [], "created": [], "deleted": [], "site": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.charge = {"updated": [], "slice": [], "created": [], "deleted": [], "amount": ["notBlank"], "object": ["notBlank"], "account": ["notBlank"], "kind": ["notBlank"], "state": ["notBlank"], "coreHours": ["notBlank"], "invoice": [], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.dashboardView = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "url": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.deployment = {"accessControl": ["notBlank"], "updated": [], "admin_user": [], "name": ["notBlank"], "created": [], "deleted": [], "availability_zone": [], "backend_type": [], "auth_url": [], "admin_password": [], "backend_status": ["notBlank"], "admin_tenant": [], "id": [], "enacted": ["notBlank"]}; + this.deploymentPrivilege = {"updated": [], "created": [], "deleted": [], "role": ["notBlank"], "user": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.deploymentRole = {"updated": [], "created": [], "deleted": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.flavor = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "order": ["notBlank"], "default": [], "flavor": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.image = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "container_format": ["notBlank"], "disk_format": ["notBlank"], "path": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.imageDeployments = {"updated": [], "created": [], "deleted": [], "image": ["notBlank"], "glance_image_id": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.invoice = {"updated": [], "created": [], "deleted": [], "account": ["notBlank"], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.network = {"controllerParameters": [], "subnet": [], "updated": [], "subnet_id": [], "topologyParameters": [], "name": ["notBlank"], "created": [], "deleted": [], "network_id": [], "labels": [], "guaranteedBandwidth": ["notBlank"], "controllerUrl": [], "ports": [], "permitAllSlices": [], "router_id": [], "template": ["notBlank"], "owner": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.networkDeployments = {"router_id": [], "subnet": [], "updated": [], "network": ["notBlank"], "created": [], "deleted": [], "net_id": [], "subnet_id": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.networkParameter = {"updated": [], "created": [], "deleted": [], "value": ["notBlank"], "object_id": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "parameter": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.networkParameterType = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.networkSlice = {"updated": [], "slice": ["notBlank"], "network": ["notBlank"], "created": [], "deleted": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.networkSliver = {"updated": [], "network": ["notBlank"], "created": [], "deleted": [], "ip": [], "sliver": ["notBlank"], "backend_status": ["notBlank"], "port_id": [], "id": [], "enacted": ["notBlank"]}; + this.networkTemplate = {"controllerKind": [], "updated": [], "name": ["notBlank"], "created": [], "deleted": [], "description": [], "sharedNetworkName": [], "guaranteedBandwidth": ["notBlank"], "visibility": ["notBlank"], "topologyKind": ["notBlank"], "sharedNetworkId": [], "translation": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.node = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "site": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.payment = {"updated": [], "created": [], "deleted": [], "account": ["notBlank"], "amount": ["notBlank"], "date": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.planetStack = {"updated": [], "description": ["notBlank"], "created": [], "deleted": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.planetStackPrivilege = {"updated": [], "created": [], "deleted": [], "planetstack": ["notBlank"], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.planetStackRole = {"updated": [], "created": [], "deleted": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.project = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.reservation = {"updated": [], "slice": ["notBlank"], "created": [], "deleted": [], "startTime": ["notBlank"], "duration": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.reservedResource = {"updated": [], "resource": ["notBlank"], "created": [], "deleted": [], "sliver": ["notBlank"], "reservationSet": ["notBlank"], "backend_status": ["notBlank"], "id": [], "quantity": ["notBlank"], "enacted": ["notBlank"]}; + this.role = {"updated": [], "description": ["notBlank"], "created": [], "deleted": [], "role": [], "content_type": ["notBlank"], "backend_status": ["notBlank"], "id": [], "role_type": ["notBlank"], "enacted": ["notBlank"]}; + this.router = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "owner": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.service = {"updated": [], "description": [], "created": [], "deleted": [], "enabled": [], "name": ["notBlank"], "versionNumber": ["notBlank"], "published": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.serviceAttribute = {"updated": [], "name": ["notBlank"], "service": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.serviceClass = {"updated": [], "membershipFee": ["notBlank"], "name": ["notBlank"], "membershipFeeMonths": ["notBlank"], "created": [], "deleted": [], "description": ["notBlank"], "commitment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "upgradeRequiresApproval": [], "enacted": ["notBlank"]}; + this.serviceResource = {"updated": [], "bucketInRate": ["notBlank"], "name": ["notBlank"], "bucketMaxSize": ["notBlank"], "created": [], "deleted": [], "serviceClass": ["notBlank"], "maxUnitsDeployment": ["notBlank"], "calendarReservable": [], "maxDuration": ["notBlank"], "maxUnitsNode": ["notBlank"], "cost": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.site = {"abbreviated_name": ["notBlank"], "updated": [], "name": ["notBlank"], "created": [], "deleted": [], "enabled": [], "longitude": [], "site_url": [], "login_base": ["notBlank"], "location": ["notBlank"], "latitude": [], "is_public": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.siteCredential = {"updated": [], "enc_value": ["notBlank"], "name": ["notBlank"], "created": [], "deleted": [], "site": ["notBlank"], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.siteDeployments = {"updated": [], "created": [], "deleted": [], "tenant_id": [], "site": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.sitePrivilege = {"updated": [], "created": [], "deleted": [], "site": ["notBlank"], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.siteRole = {"updated": [], "created": [], "deleted": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.slice = {"updated": [], "imagePreference": [], "name": ["notBlank"], "service": [], "created": [], "deleted": [], "slice_url": [], "description": [], "serviceClass": ["notBlank"], "enabled": [], "site": ["notBlank"], "omf_friendly": [], "network": [], "max_slivers": ["notBlank"], "mountDataSets": [], "backend_status": ["notBlank"], "creator": [], "id": [], "enacted": ["notBlank"]}; + this.sliceCredential = {"updated": [], "slice": ["notBlank"], "enc_value": ["notBlank"], "name": ["notBlank"], "created": [], "deleted": [], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.sliceDeployments = {"router_id": [], "updated": [], "slice": ["notBlank"], "created": [], "deleted": [], "tenant_id": [], "subnet_id": [], "network_id": [], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.slicePrivilege = {"updated": [], "slice": ["notBlank"], "created": [], "deleted": [], "role": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.sliceRole = {"updated": [], "created": [], "deleted": [], "role": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.sliceTag = {"updated": [], "slice": ["notBlank"], "name": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.sliver = {"node": ["notBlank"], "instance_name": [], "updated": [], "slice": ["notBlank"], "deploymentNetwork": ["notBlank"], "name": ["notBlank"], "created": [], "deleted": [], "ip": [], "image": ["notBlank"], "creator": [], "numberCores": ["notBlank"], "instance_id": [], "userData": [], "flavor": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.tag = {"updated": [], "name": ["notBlank"], "service": ["notBlank"], "created": [], "deleted": [], "value": ["notBlank"], "object_id": ["notBlank"], "content_type": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.usableObject = {"updated": [], "name": ["notBlank"], "created": [], "deleted": [], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.user = {"username": ["notBlank"], "public_key": [], "updated": [], "backend_status": ["notBlank"], "is_readonly": [], "firstname": ["notBlank"], "user_url": [], "deleted": [], "lastname": ["notBlank"], "created": [], "is_active": [], "site": ["notBlank"], "email": ["notBlank"], "phone": [], "is_staff": [], "last_login": ["notBlank"], "timezone": ["notBlank"], "is_admin": [], "password": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.userCredential = {"updated": [], "enc_value": ["notBlank"], "name": ["notBlank"], "created": [], "deleted": [], "user": ["notBlank"], "key_id": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.userDashboardView = {"updated": [], "created": [], "deleted": [], "dashboardView": ["notBlank"], "order": ["notBlank"], "user": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; + this.userDeployments = {"updated": [], "created": [], "deleted": [], "kuser_id": [], "user": ["notBlank"], "deployment": ["notBlank"], "backend_status": ["notBlank"], "id": [], "enacted": ["notBlank"]}; }; -xosdefaults = new xos_get_defaults(); +xosvalidators = new xos_get_validators(); diff --git a/planetstack/core/xoslib/tools/make_validators.py b/planetstack/core/xoslib/tools/make_validators.py index ad5377c..0fca367 100644 --- a/planetstack/core/xoslib/tools/make_validators.py +++ b/planetstack/core/xoslib/tools/make_validators.py @@ -12,7 +12,7 @@ import inspect from django.core import serializers import json -print "function xos_get_defaults() {" +print "function xos_get_validators() {" for c in dir(core.models): c = getattr(core.models,c) @@ -24,18 +24,12 @@ for c in dir(core.models): if (classname in ["plCoreBase", "singletonModel"]): continue - fieldNames = [f.name for f in c._meta.fields] - - fields = json.loads(serializers.serialize("json",[c],fields=fieldNames))[0]["fields"] - - for f in fields.keys(): - if f in ['created', 'updated', 'enacted']: - fields[f] = None + fields = c.getValidators(); fields_json = json.dumps(fields) print " this." + classname + " = " + fields_json + ";" print "};" -print "xosdefaults = new xos_get_defaults();" +print "xosvalidators = new xos_get_validators();" -- 2.43.0