Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
where
Commits
905e75d4
Commit
905e75d4
authored
Feb 24, 2020
by
Zach Perkins
Browse files
Got rid of as_json methods
parent
df973667
Changes
1
Hide whitespace changes
Inline
Side-by-side
where/model/models.py
View file @
905e75d4
...
...
@@ -34,6 +34,7 @@ class Point(Base):
super
(
Point
,
self
).
__init__
(
**
kwargs
)
@
validates
(
'attributes'
)
def
validate_data
(
self
,
_
,
data
):
if
data
is
None
:
...
...
@@ -51,18 +52,6 @@ class Point(Base):
field
.
validate_data
(
data
[
key
])
return
data
def
as_json
(
self
,
children
=
True
):
if
children
:
children
=
[
child
.
as_json
(
children
=
False
)
for
child
in
self
.
children
]
return
{
"name"
:
self
.
name
,
"lat"
:
self
.
lat
,
"lon"
:
self
.
lon
,
"category"
:
self
.
category
.
id
,
"attributes"
:
self
.
attributes
,
"children"
:
children
}
class
Category
(
Base
):
"""
...
...
@@ -76,14 +65,6 @@ class Category(Base):
fields
=
relationship
(
"Field"
)
def
as_json
(
self
):
return
{
"id"
:
self
.
id
,
"name"
:
self
.
name
,
"icon"
:
self
.
icon
,
"attributes"
:
{
attr
.
slug
:
attr
.
as_json
()
for
attr
in
self
.
fields
}
}
class
Field
(
Base
):
"""
...
...
@@ -104,10 +85,3 @@ class Field(Base):
Verify that data is the correct type for this Field.
"""
self
.
type
.
validate
(
data
)
def
as_json
(
self
):
return
{
"slug"
:
self
.
slug
,
"name"
:
self
.
name
,
"type"
:
self
.
type
.
name
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment