author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 16 Jun 2016 14:19:20 +0200 | |
changeset 11278 | 19fcce6dc6d1 |
parent 10907 | 9ae707db5265 |
permissions | -rw-r--r-- |
10487
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
1 |
"""entity/relation schemas to store email in an cubicweb instance |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
2 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
3 |
:organization: Logilab |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
4 |
:copyright: 2006-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
6 |
""" |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
7 |
__docformat__ = "restructuredtext en" |
10666
7f6b5f023884
[py3k] replace '_ = unicode' in global scope (closes #7589459)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10487
diff
changeset
|
8 |
from cubicweb import _ |
10487
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
9 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
10 |
# pylint: disable-msg=E0611,F0401 |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
11 |
from yams.buildobjs import (SubjectRelation, RelationType, EntityType, |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
12 |
String, Datetime, Int, RelationDefinition) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
13 |
from yams.reader import context |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
14 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
15 |
from cubicweb.schema import ERQLExpression |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
16 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
17 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
18 |
class Email(EntityType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
19 |
"""electronic mail""" |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
20 |
subject = String(fulltextindexed=True) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
21 |
date = Datetime(description=_('UTC time on which the mail was sent')) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
22 |
messageid = String(required=True, indexed=True) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
23 |
headers = String(description=_('raw headers')) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
24 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
25 |
sender = SubjectRelation('EmailAddress', cardinality='?*') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
26 |
# an email with only Bcc is acceptable, don't require any recipients |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
27 |
recipients = SubjectRelation('EmailAddress') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
28 |
cc = SubjectRelation('EmailAddress') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
29 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
30 |
parts = SubjectRelation('EmailPart', cardinality='*1', composite='subject') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
31 |
attachment = SubjectRelation('File') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
32 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
33 |
reply_to = SubjectRelation('Email', cardinality='?*') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
34 |
cites = SubjectRelation('Email') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
35 |
in_thread = SubjectRelation('EmailThread', cardinality='?*') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
36 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
37 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
38 |
class EmailPart(EntityType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
39 |
"""an email attachment""" |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
40 |
__permissions__ = { |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
41 |
'read': ('managers', 'users', 'guests',), # XXX if E parts X, U has_read_permission E |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
42 |
'add': ('managers', ERQLExpression('E parts X, U has_update_permission E'),), |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
43 |
'delete': ('managers', ERQLExpression('E parts X, U has_update_permission E')), |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
44 |
'update': ('managers', 'owners',), |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
45 |
} |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
46 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
47 |
content = String(fulltextindexed=True) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
48 |
content_format = String(required=True, maxsize=50) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
49 |
ordernum = Int(required=True) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
50 |
alternative = SubjectRelation('EmailPart', symmetric=True) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
51 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
52 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
53 |
class EmailThread(EntityType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
54 |
"""discussion thread""" |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
55 |
title = String(required=True, indexed=True, fulltextindexed=True) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
56 |
see_also = SubjectRelation('EmailThread') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
57 |
forked_from = SubjectRelation('EmailThread', cardinality='?*') |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
58 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
59 |
class parts(RelationType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
60 |
""" """ |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
61 |
fulltext_container = 'subject' |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
62 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
63 |
class sender(RelationType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
64 |
""" """ |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
65 |
inlined = True |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
66 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
67 |
class in_thread(RelationType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
68 |
""" """ |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
69 |
inlined = True |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
70 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
71 |
class reply_to(RelationType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
72 |
""" """ |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
73 |
inlined = True |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
74 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
75 |
class generated_by(RelationType): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
76 |
"""mark an entity as generated from an email""" |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
77 |
cardinality = '?*' |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
78 |
subject = ('TrInfo',) |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
79 |
object = 'Email' |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
80 |
|
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
81 |
# if comment is installed |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
82 |
if 'Comment' in context.defined: |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
83 |
class comment_generated_by(RelationDefinition): |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
84 |
subject = 'Comment' |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
85 |
name = 'generated_by' |
49a5c38de1de
[server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
86 |
object = 'Email' |