[schema] use definition for `use_email` relation instead of type declaration (closes: #1894929) stable
authorJulien Jehannet <julien.jehannet@logilab.fr>
Wed, 03 Aug 2011 13:28:06 +0200
branchstable
changeset 7733 432e1f0d4857
parent 7732 5430d0db52ab
child 7734 59fea81647e5
[schema] use definition for `use_email` relation instead of type declaration (closes: #1894929) This will be more adaptable for other existent `use_relastion` as the one in the cube Person.
schemas/base.py
--- a/schemas/base.py	Thu Aug 04 12:11:36 2011 +0200
+++ b/schemas/base.py	Wed Aug 03 13:28:06 2011 +0200
@@ -46,8 +46,6 @@
     # test at least :-/
     primary_email = SubjectRelation('EmailAddress', cardinality='??',
                                     description=_('email address to use for notification'))
-    use_email     = SubjectRelation('EmailAddress', cardinality='*?', composite='subject')
-
     in_group = SubjectRelation('CWGroup', cardinality='+*',
                                constraints=[RQLConstraint('NOT O name "owners"')],
                                description=_('groups grant permissions to the user'))
@@ -71,13 +69,20 @@
 to indicate which is the preferred form.'))
 
 class use_email(RelationType):
-    """ """
+    fulltext_container = 'subject'
+
+class use_email_relation(RelationDefinition):
+    """user's email account"""
+    name = "use_email"
     __permissions__ = {
         'read':   ('managers', 'users', 'guests',),
         'add':    ('managers', RRQLExpression('U has_update_permission S'),),
         'delete': ('managers', RRQLExpression('U has_update_permission S'),),
         }
-    fulltext_container = 'subject'
+    subject = "CWUser"
+    object = "EmailAddress"
+    cardinality = '*?'
+    composite = 'subject'
 
 class primary_email(RelationType):
     """the prefered email"""