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
basket
Commits
75ab08a4dabf
Commit
5c41c775
authored
Dec 08, 2009
by
Sandrine Ribeau
Browse files
cw 3.6 api update
parent
b146fb0e55c3
Changes
2
Hide whitespace changes
Inline
Side-by-side
schema.py
View file @
75ab08a4
...
...
@@ -8,7 +8,7 @@ from cubicweb.schema import ERQLExpression
class
Basket
(
EntityType
):
"""a basket contains a set of other entities"""
permissions
=
{
__
permissions
__
=
{
'read'
:
(
'managers'
,
ERQLExpression
(
'X owned_by U'
),),
'add'
:
(
'managers'
,
'users'
,),
'delete'
:
(
'managers'
,
'owners'
,),
...
...
views.py
View file @
75ab08a4
...
...
@@ -29,19 +29,19 @@ class BasketPrimaryView(baseviews.PrimaryView):
def
display_title
(
self
,
entity
):
self
.
w
(
u
"<span class='title'><b>%s : %s</b></span>"
%
(
self
.
req
.
_
(
self
.
entity_name
),
html_escape
(
entity
.
name
)))
self
.
_cw
.
_
(
self
.
entity_name
),
html_escape
(
entity
.
name
)))
def
display_content
(
self
,
entity
):
rset
=
self
.
req
.
execute
(
'Any I WHERE I in_basket B, B eid %(x)s'
,
rset
=
self
.
_cw
.
execute
(
'Any I WHERE I in_basket B, B eid %(x)s'
,
{
'x'
:
entity
.
eid
},
'x'
)
self
.
w
(
'<h5>%s</h5>'
%
self
.
req
.
_
(
self
.
content_msg
))
self
.
w
(
'<h5>%s</h5>'
%
self
.
_cw
.
_
(
self
.
content_msg
))
if
rset
:
self
.
wview
(
'list'
,
rset
)
else
:
self
.
w
(
self
.
req
.
_
(
self
.
nothing_msg
))
self
.
w
(
self
.
_cw
.
_
(
self
.
nothing_msg
))
def
cell_call
(
self
,
row
,
col
):
entity
=
self
.
complete_entity
(
row
,
col
)
entity
=
self
.
cw_rset
.
complete_entity
(
row
,
col
)
self
.
w
(
u
' '
)
self
.
display_title
(
entity
)
if
entity
.
description
:
...
...
@@ -69,7 +69,7 @@ def insert_eids(actions, eids):
class
BasketBox
(
box
.
UserRQLBoxTemplate
):
"""display a box containing all user's basketitems"""
id
=
'basket_box'
__regid__
=
'basket_box'
visible
=
False
# disabled by default
order
=
30
title
=
_
(
'basket'
)
...
...
@@ -84,7 +84,7 @@ class BasketBox(box.UserRQLBoxTemplate):
# something is being displayed. If the first column contains eids,
# fetch them so we can propose to add the selection to the basket
etype
=
iter
(
self
.
rset
.
column_types
(
0
)).
next
()
if
not
self
.
schema
.
eschema
(
etype
).
is_final
():
if
not
self
.
_cw
.
vreg
.
schema
.
eschema
(
etype
).
is_final
():
selectedeids
=
set
(
row
[
0
]
for
row
in
self
.
rset
.
rows
)
return
selectedeids
...
...
@@ -119,14 +119,14 @@ class BasketBox(box.UserRQLBoxTemplate):
def
call
(
self
,
**
kwargs
):
try
:
baskets
=
self
.
req
.
execute
(
*
self
.
to_display_rql
())
baskets
=
self
.
_cw
.
execute
(
*
self
.
to_display_rql
())
except
Unauthorized
:
# can't access to something in the query, forget this box
return
_
=
self
.
req
.
_
req
=
self
.
req
_
=
self
.
_cw
.
_
req
=
self
.
_cw
box
=
BoxWidget
(
_
(
self
.
title
),
self
.
id
)
rschema
=
self
.
schema
.
rschema
(
self
.
rtype
)
rschema
=
self
.
_cw
.
vreg
.
schema
.
rschema
(
self
.
rtype
)
actions
=
[]
rql
=
req
.
form
.
get
(
'rql'
)
or
kwargs
.
get
(
'rql'
)
or
''
vid
=
req
.
form
.
get
(
'vid'
,
''
)
...
...
@@ -142,7 +142,7 @@ class BasketBox(box.UserRQLBoxTemplate):
continue
if
rschema
.
has_perm
(
req
,
'delete'
):
self
.
build_delete_link
(
box
,
basket
,
inbasketeids
,
rql
,
vid
)
eschema
=
self
.
schema
.
eschema
(
self
.
etype
)
eschema
=
self
.
_cw
.
vreg
.
schema
.
eschema
(
self
.
etype
)
if
eschema
.
has_perm
(
req
,
'add'
):
actions
.
append
(
self
.
mk_action
(
_
(
'create basket'
),
self
.
create_url
(
self
.
etype
),
...
...
@@ -155,11 +155,11 @@ class SelectBasketContentAction(action.Action):
category
=
'mainactions'
__select__
=
implements
(
'Basket'
)
id
=
'select_basket_content'
__regid__
=
'select_basket_content'
title
=
_
(
'actions_select_basket_content'
)
def
url
(
self
):
rql
=
u
'Any X WHERE X in_basket B, B eid %s'
%
self
.
rset
[
self
.
row
or
0
][
self
.
col
or
0
]
return
self
.
build_url
(
rql
=
rql
)
rql
=
u
'Any X WHERE X in_basket B, B eid %s'
%
self
.
cw_
rset
[
self
.
cw_
row
or
0
][
self
.
cw_
col
or
0
]
return
self
.
_cw
.
build_url
(
rql
=
rql
)
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