Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
tuto
Commits
2d0c34ecb320
Commit
deb1c246
authored
Mar 10, 2021
by
Frank Bessou
🍁
Browse files
feat: add attribute constraints to Museum and City
parent
7e2fc86cbc10
Pipeline
#39579
passed with stage
in 1 minute and 12 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
cubicweb_tuto/schema.py
View file @
2d0c34ec
...
...
@@ -17,20 +17,26 @@
"""cubicweb-tuto schema"""
from
yams.buildobjs
import
EntityType
,
String
,
Float
,
SubjectRelation
,
Int
from
yams.constraints
import
BoundaryConstraint
class
Museum
(
EntityType
):
name
=
String
()
latitude
=
Float
()
longitude
=
Float
()
name
=
String
(
required
=
True
)
latitude
=
Float
(
constraints
=
[
BoundaryConstraint
(
">="
,
-
90
),
BoundaryConstraint
(
"<="
,
90
)]
)
longitude
=
Float
(
constraints
=
[
BoundaryConstraint
(
">="
,
-
180
),
BoundaryConstraint
(
"<="
,
180
)]
)
is_in
=
SubjectRelation
(
"City"
,
cardinality
=
"1*"
)
director
=
SubjectRelation
(
"Person"
,
cardinality
=
"**"
)
postal_address
=
String
()
class
City
(
EntityType
):
name
=
String
()
name
=
String
(
required
=
True
)
zip_code
=
Int
()
country
=
String
(
default
=
"France"
)
class
Person
(
EntityType
):
...
...
Write
Preview
Supports
Markdown
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