Skip to content
This repository has been archived by the owner on Nov 28, 2021. It is now read-only.

Commit

Permalink
started work on #139
Browse files Browse the repository at this point in the history
  • Loading branch information
BradMclain committed Oct 5, 2016
1 parent 635d2fa commit a24cb8d
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 26 deletions.
80 changes: 54 additions & 26 deletions prestans/devel/gen/closure.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class BasicTypeElementTemplate(object):
def __init__(self, blueprint_type, blueprint):

self._blueprint_type = blueprint_type

self._required = None
self._default = None
self._minimum = None
Expand All @@ -59,34 +60,54 @@ def __init__(self, blueprint_type, blueprint):
self._choices = None
self._format = None
self._trim = None
self._allowed_mime_types = None

if self._blueprint_type == "string":
self._required = blueprint['required']
self._min_length = blueprint['min_length']
self._max_length = blueprint['max_length']
self._default = blueprint['default']
self._choices = blueprint['choices']
self._format = blueprint['format']
self._trim = blueprint['trim']
self._client_class_name = "String"
elif self._blueprint_type == 'integer':
self._required = blueprint['required']
self._default = blueprint['default']
self._minimum = blueprint['minimum']
self._maximum = blueprint['maximum']
self._choices = blueprint['choices']
self._client_class_name = "Integer"
elif self._blueprint_type == 'float':
self._required = blueprint['required']
self._default = blueprint['default']
self._minimum = blueprint['minimum']
self._maximum = blueprint['maximum']
self._choices = blueprint['choices']
self._client_class_name = "Float"
elif self._blueprint_type == 'boolean':
self._required = blueprint['required']
self._default = blueprint['default']
if self._blueprint_type == "boolean":
self._required = blueprint["required"]
self._default = blueprint["default"]
self._client_class_name = "Boolean"
elif self._blueprint_type == "data_url_file":
self._required = blueprint["required"]
self._allowed_mime_types = blueprint["allowed_mime_types"]
self._client_class_name = "DataURLFile"
elif self._blueprint_type == "date":
self._required = blueprint["required"]
self._default = blueprint["default"]
self._format = blueprint["format"]
self._client_class_name = "Date"
elif self._blueprint_type == "datetime":
self._required = blueprint["required"]
self._default = blueprint["default"]
self._format = blueprint["format"]
self._client_class_name = "DateTime"
elif self._blueprint_type == "float":
self._required = blueprint["required"]
self._default = blueprint["default"]
self._minimum = blueprint["minimum"]
self._maximum = blueprint["maximum"]
self._choices = blueprint["choices"]
self._client_class_name = "Float"
elif self._blueprint_type == "integer":
self._required = blueprint["required"]
self._default = blueprint["default"]
self._minimum = blueprint["minimum"]
self._maximum = blueprint["maximum"]
self._choices = blueprint["choices"]
self._client_class_name = "Integer"
elif self._blueprint_type == "string":
self._required = blueprint["required"]
self._min_length = blueprint["min_length"]
self._max_length = blueprint["max_length"]
self._default = blueprint["default"]
self._choices = blueprint["choices"]
self._format = blueprint["format"]
self._trim = blueprint["trim"]
self._client_class_name = "String"
elif self._blueprint_type == "time":
self._required = blueprint["required"]
self._default = blueprint["default"]
self._format = blueprint["format"]
self._client_class_name = "Time"

if self._required is None:
self._required = True
Expand Down Expand Up @@ -178,6 +199,13 @@ def choices(self):
else:
return self._choices

@property
def allowed_mime_types(self):
if self._allowed_mime_types is None:
return "null"
else:
return self._allowed_mime_types


class AttributeMetaData(object):

Expand Down
33 changes: 33 additions & 0 deletions prestans/devel/gen/templates/closure/model/macro.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,39 @@
opt_maxLength: {{attribute.max_length}},
opt_minLength: {{attribute.min_length}}
}, opt_raiseValidateException);
{% elif attribute.element_template.blueprint_type == 'data_url_file' %}
this.{{attribute.ccif}}_ = new prestans.types.Array({
elementTemplate: new prestans.types.DataURLFile({
required: {{attribute.element_template.required}},
allowedMimeTypes: {{attribute.element_template.allowed_mime_types}}
}),
opt_json: opt_json[{{namespace}}.{{name}}.REWRITE_MAP["{{attribute.name}}"]]
}, opt_raiseValidateException);
{% elif attribute.element_template.blueprint_type == 'date' %}
this.{{attribute.ccif}}_ = new prestans.types.Array({
elementTemplate: new prestans.types.Date({
required: {{attribute.element_template.required}},
defaultValue: {{attribute.element_template.default}}
}),
opt_json: opt_json[{{namespace}}.{{name}}.REWRITE_MAP["{{attribute.name}}"]]
}, opt_raiseValidateException);
{% elif attribute.element_template.blueprint_type == 'datetime' %}
this.{{attribute.ccif}}_ = new prestans.types.Array({
elementTemplate: new prestans.types.DateTime({
required: {{attribute.element_template.required}},
defaultValue: {{attribute.element_template.default}}
}),
opt_json: opt_json[{{namespace}}.{{name}}.REWRITE_MAP["{{attribute.name}}"]]
}, opt_raiseValidateException);
{% elif attribute.element_template.blueprint_type == 'time' %}
this.{{attribute.ccif}}_ = new prestans.types.Array({
elementTemplate: new prestans.types.Time({
required: {{attribute.element_template.required}},
defaultValue: {{attribute.element_template.default}},
format: {{attribute.element_template.format}}
}),
opt_json: opt_json[{{namespace}}.{{name}}.REWRITE_MAP["{{attribute.name}}"]]
}, opt_raiseValidateException);
{% endif %}
{% elif attribute.blueprint_type == 'string' %}
this.{{attribute.ccif}}_ = new prestans.types.String({
Expand Down

0 comments on commit a24cb8d

Please sign in to comment.