Commit fad9879e authored by Julien Jehannet's avatar Julien Jehannet
Browse files

[schema] explicit declaration of the `use_email` permission

Since permissions are no more set in RetationType class, we have to write them
explicitly in this cube's schema.

--HG--
branch : stable
parent 12c955336241
from yams.buildobjs import EntityType, SubjectRelation, String
from yams.buildobjs import EntityType, RelationDefinition, SubjectRelation, String
try:
from yams.buildobjs import RichString
......@@ -7,7 +7,7 @@ try:
except ImportError:
from cubicweb.schema import RichString
from cubicweb.schema import RQLConstraint
from cubicweb.schema import RRQLExpression, RQLConstraint
_ = unicode
......@@ -28,10 +28,30 @@ class Person(EntityType):
if 'IMAddress' in defined_types:
im_address = SubjectRelation('IMAddress', composite='subject')
use_email = SubjectRelation('EmailAddress', cardinality='*1', composite='subject')
# allowing an email to be the primary email of multiple persons is necessary for
# test at least :-/
primary_email = SubjectRelation('EmailAddress', cardinality='??',
constraints= [RQLConstraint('S use_email O')])
class use_email(RelationDefinition):
"""person's email account"""
__permissions__ = {
'read': ('managers', 'users', 'guests',),
'add': ('managers', RRQLExpression('U has_update_permission S'),),
'delete': ('managers', RRQLExpression('U has_update_permission S'),),
}
subject = "Person"
object = "EmailAddress"
cardinality = '*?'
composite = 'subject'
class primary_email(RelationDefinition):
"""person's primary email account"""
__permissions__ = {
'read': ('managers', 'users', 'guests',),
'add': ('managers', RRQLExpression('U has_update_permission S'),),
'delete': ('managers', RRQLExpression('U has_update_permission S'),),
}
subject = "Person"
object = "EmailAddress"
cardinality = '??'
constraints= [RQLConstraint('S use_email O')]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment