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
person
Commits
6591eea27e4b
Commit
8f875532
authored
Dec 10, 2009
by
Sandrine Ribeau
Browse files
api-update
parent
84380c553af4
Changes
3
Hide whitespace changes
Inline
Side-by-side
entities.py
View file @
6591eea2
...
...
@@ -12,7 +12,7 @@ from cubicweb.entities import AnyEntity, fetch_config
class
Person
(
EmailableMixIn
,
AnyEntity
):
"""customized class for Person entities"""
id
=
'Person'
__regid__
=
'Person'
fetch_attrs
,
fetch_order
=
fetch_config
([
'surname'
,
'firstname'
])
rest_attr
=
'surname'
skip_copy_for
=
(
'primary_email'
,)
...
...
@@ -25,7 +25,7 @@ class Person(EmailableMixIn, AnyEntity):
def
name
(
self
,
civility
=
False
):
if
civility
and
self
.
civility
:
return
u
'%s %s %s'
%
(
self
.
req
.
_
(
self
.
civility
),
return
u
'%s %s %s'
%
(
self
.
_cw
.
_
(
self
.
civility
),
self
.
firstname
or
u
''
,
self
.
surname
or
u
''
)
return
u
'%s %s'
%
(
self
.
firstname
or
u
''
,
self
.
surname
or
u
''
)
...
...
test/unittest_person.py
View file @
6591eea2
from
logilab.common.testlib
import
unittest_main
from
cubicweb.devtools.
app
test
import
EnvBased
TC
from
cubicweb.devtools.test
lib
import
CubicWeb
TC
class
PersonTC
(
EnvBased
TC
):
class
PersonTC
(
CubicWeb
TC
):
def
setup_database
(
self
):
self
.
add
_entity
(
'Person'
,
firstname
=
u
'adrien'
,
surname
=
u
'di mascio'
)
self
.
request
().
create
_entity
(
'Person'
,
firstname
=
u
'adrien'
,
surname
=
u
'di mascio'
)
def
test_dc_title
(
self
):
e
=
self
.
entity
(
'Any X WHERE X is Person'
)
...
...
views.py
View file @
6591eea2
...
...
@@ -18,8 +18,8 @@ for attr in ('civility', 'description', 'firstname', 'surname'):
for
rtype
in
(
'phone'
,
'use_email'
,
'primary_email'
):
uicfg
.
primaryview_section
.
tag_subject_of
((
'Person'
,
rtype
,
'*'
),
'hidden'
)
uicfg
.
autoform_
is_inlined
.
tag_subject_of
((
'Person'
,
'phone'
,
'*'
),
True
)
uicfg
.
autoform_
is_inlined
.
tag_subject_of
((
'Person'
,
'postal_address'
,
'*'
),
True
)
uicfg
.
autoform_
section
.
tag_subject_of
((
'Person'
,
'phone'
,
'*'
),
'main'
,
'inlined'
)
uicfg
.
autoform_
section
.
tag_subject_of
((
'Person'
,
'postal_address'
,
'*'
),
'main'
,
'inlined'
)
class
PersonPrimaryView
(
primary
.
PrimaryView
):
__select__
=
implements
(
'Person'
)
...
...
@@ -39,7 +39,7 @@ class PersonPrimaryView(primary.PrimaryView):
self
.
w
(
u
"<table>"
)
for
postaladdress
in
entity
.
postal_address
:
self
.
w
(
u
'<tr><th class="labelCol">%s</th><td>%s</td></tr>'
%
(
display_name
(
self
.
req
,
'PostalAddress'
),
(
display_name
(
self
.
_cw
,
'PostalAddress'
),
postaladdress
.
view
(
'incontext'
))
)
self
.
w
(
u
"</table>"
)
...
...
@@ -47,7 +47,7 @@ class PersonPrimaryView(primary.PrimaryView):
self
.
w
(
u
"<table>"
)
for
imaddress
in
entity
.
im_address
:
self
.
w
(
u
'<tr><th class="labelCol">%s</th><td>%s</td></tr>'
%
(
display_name
(
self
.
req
,
'IMAddress'
),
(
display_name
(
self
.
_cw
,
'IMAddress'
),
imaddress
.
view
(
'incontext'
))
)
self
.
w
(
u
"</table>"
)
super
(
PersonPrimaryView
,
self
).
render_entity_attributes
(
entity
)
...
...
@@ -60,20 +60,20 @@ class PersonTextView(baseviews.TextView):
__select__
=
implements
(
'Person'
)
def
cell_call
(
self
,
row
,
col
):
entity
=
self
.
entity
(
row
,
col
)
entity
=
self
.
cw_rset
.
get_
entity
(
row
,
col
)
self
.
w
(
entity
.
name
())
class
PersonEmailView
(
baseviews
.
EntityView
):
"""display emails sent or received by one of this person's addresses"""
id
=
'emails'
__regid__
=
'emails'
__select__
=
implements
(
'Person'
)
title
=
_
(
'emails'
)
def
cell_call
(
self
,
row
,
col
=
0
):
entity
=
self
.
entity
(
row
,
col
)
entity
=
self
.
cw_rset
.
get_
entity
(
row
,
col
)
self
.
w
(
u
'<h3>'
)
self
.
w
(
self
.
req
.
_
(
'emails sent or received by %s'
)
self
.
w
(
self
.
_cw
.
_
(
'emails sent or received by %s'
)
%
xml_escape
(
entity
.
dc_title
()))
self
.
w
(
u
'</h3>'
)
done
=
set
()
...
...
@@ -113,7 +113,7 @@ class VCardPersonView(vcard.VCardCWUserView):
## actions ####################################################################
class
AddPersonFromEmailAction
(
action
.
LinkToEntityAction
):
id
=
'addperson-fromemail'
__regid__
=
'addperson-fromemail'
__select__
=
implements
(
'EmailAddress'
)
&
rql_condition
(
'NOT P use_email X'
)
title
=
_
(
'add Person use_email EmailAddress object'
)
...
...
@@ -124,6 +124,6 @@ class AddPersonFromEmailAction(action.LinkToEntityAction):
## facets #####################################################################
class
CivilityFacet
(
AttributeFacet
):
id
=
'civility-facet'
__regid__
=
'civility-facet'
__select__
=
implements
(
'Person'
)
rtype
=
'civility'
Write
Preview
Markdown
is supported
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