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
email
Commits
bb86ab386838
Commit
f4cac1a4
authored
Dec 09, 2009
by
Sylvain Thénault
Browse files
some 3.6 api update
parent
19fba397f9ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
entities.py
View file @
bb86ab38
...
...
@@ -11,7 +11,7 @@ import re
from
logilab.common
import
umessage
from
cubicweb.interfaces
import
ITree
from
cubicweb.
common.
mixins
import
TreeMixIn
from
cubicweb.mixins
import
TreeMixIn
from
cubicweb.entities
import
AnyEntity
,
fetch_config
from
cubes.email.emailcites
import
parse_body
...
...
@@ -19,7 +19,7 @@ from cubes.email.emailcites import parse_body
class
Email
(
TreeMixIn
,
AnyEntity
):
"""customized class for Email entities"""
id
=
'Email'
__regid__
=
'Email'
fetch_attrs
,
fetch_order
=
fetch_config
([
'subject'
])
__implements__
=
AnyEntity
.
__implements__
+
(
ITree
,)
...
...
@@ -100,7 +100,7 @@ class Email(TreeMixIn, AnyEntity):
class
EmailPart
(
AnyEntity
):
"""customized class for EmailPart entities"""
id
=
'EmailPart'
__regid__
=
'EmailPart'
def
dc_title
(
self
):
return
'%s (%s %s)'
%
(
self
.
email
.
subject
,
...
...
@@ -126,7 +126,7 @@ class EmailPart(AnyEntity):
class
EmailThread
(
AnyEntity
):
"""customized class for EmailThread entities"""
id
=
'EmailThread'
__regid__
=
'EmailThread'
fetch_attrs
,
fetch_order
=
fetch_config
([
'title'
])
def
dc_title
(
self
):
...
...
hooks.py
View file @
bb86ab38
...
...
@@ -15,9 +15,9 @@ import re
from
logilab.mtconverter
import
TransformError
from
cubicweb
import
UnknownEid
from
cubicweb.
server.pool
import
PreCommitOperation
from
cubicweb.se
rver.hooksmanager
import
Hook
from
cubicweb.
common.mail
import
parse_message_id
from
cubicweb.
mail
import
parse_message_id
from
cubicweb.se
lectors
import
entity_implements
from
cubicweb.
server
import
hook
def
fix_ownership
(
session
,
eid
,
email
):
...
...
@@ -31,7 +31,7 @@ def fix_ownership(session, eid, email):
{
'x'
:
eid
,
'u'
:
sender
.
eid
},
'x'
)
class
ExtractEmailInformation
(
PreCommit
Operation
):
class
ExtractEmailInformation
(
hook
.
Operation
):
"""generate a comment on the original entity if supported"""
def
precommit_event
(
self
):
...
...
@@ -67,7 +67,7 @@ class ExtractEmailInformation(PreCommitOperation):
fix_ownership
(
self
.
session
,
com
[
0
][
0
],
self
.
email
)
class
ExtractEmailChangeState
(
PreCommit
Operation
):
class
ExtractEmailChangeState
(
hook
.
Operation
):
"""check if there are some change state instruction in the mail content"""
instr_rgx
=
re
.
compile
(
':(\w+):\s*#?(\d+)'
,
re
.
U
)
...
...
@@ -108,19 +108,20 @@ class ExtractEmailChangeState(PreCommitOperation):
fix_ownership
(
self
.
session
,
trinfo
.
eid
,
self
.
email
)
class
AddEmailHook
(
Hook
):
class
AddEmailHook
(
hook
.
Hook
):
"""an email has been added, check if associated content should be created
"""
__regid__
=
'extractmailcontent'
__select__
=
hook
.
Hook
.
__select__
&
entity_implements
(
'Email'
)
events
=
(
'after_add_entity'
,)
accepts
=
(
'Email'
,)
def
call
(
self
,
session
,
entity
):
if
'comments'
in
se
ssion
.
repo
.
schema
:
for
msgid
in
entity
.
references
():
def
__
call
__
(
self
):
if
'comments'
in
se
lf
.
_cw
.
repo
.
schema
:
for
msgid
in
self
.
entity
.
references
():
info
=
parse_message_id
(
msgid
,
self
.
config
.
appid
)
self
.
info
(
'extracted information from message id %s: %s'
,
msgid
,
info
)
if
info
:
ExtractEmailInformation
(
se
ssion
,
email
=
entity
,
info
=
info
)
ExtractEmailInformation
(
se
lf
.
_cw
,
email
=
self
.
entity
,
info
=
info
)
break
ExtractEmailChangeState
(
se
ssion
,
email
=
entity
)
ExtractEmailChangeState
(
se
lf
.
_cw
,
email
=
self
.
entity
)
schema.py
View file @
bb86ab38
...
...
@@ -40,7 +40,7 @@ class Email(EntityType):
class
EmailPart
(
EntityType
):
"""an email attachment"""
permissions
=
{
__
permissions
__
=
{
'read'
:
(
'managers'
,
'users'
,
'guests'
,),
# XXX if E parts X, U has_read_permission E
'add'
:
(
'managers'
,
ERQLExpression
(
'E parts X, U has_update_permission E'
),),
'delete'
:
(
'managers'
,
ERQLExpression
(
'E parts X, U has_update_permission E'
)),
...
...
views/email.py
View file @
bb86ab38
...
...
@@ -10,8 +10,8 @@ _ = unicode
from
logilab.mtconverter
import
xml_escape
from
cubicweb.selectors
import
implements
from
cubicweb.
common.
uilib
import
soup2xhtml
from
cubicweb.
common.
mixins
import
TreeViewMixIn
from
cubicweb.uilib
import
soup2xhtml
from
cubicweb.mixins
import
TreeViewMixIn
from
cubicweb.web
import
uicfg
,
formwidgets
from
cubicweb.web.views
import
baseviews
,
primary
...
...
@@ -74,7 +74,7 @@ class EmailPrimaryView(primary.PrimaryView):
class
EmailHeadersView
(
baseviews
.
EntityView
):
"""display email's headers"""
id
=
'headers'
__regid__
=
'headers'
__select__
=
implements
(
'Email'
)
title
=
_
(
'headers'
)
templatable
=
False
...
...
@@ -112,13 +112,13 @@ class EmailOneLineView(baseviews.OneLineView):
class
EmailOutOfContextView
(
EmailOneLineView
):
"""short view outside the context of the email"""
id
=
'outofcontext'
__regid__
=
'outofcontext'
title
=
_
(
'out of context'
)
class
EmailInContextView
(
EmailOneLineView
):
"""short view inside the context of the email"""
id
=
'incontext'
__regid__
=
'incontext'
class
EmailPartOutOfContextView
(
baseviews
.
OutOfContextView
):
...
...
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