Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
basket
Commits
70af8f6664c6
Commit
9f170e7c
authored
Jan 25, 2010
by
Sylvain Thénault
Browse files
cw 3.6 api updates
parent
05236934a8a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
views.py
View file @
70af8f66
"""Specific views for baskets
:organization: Logilab
:copyright: 2003-200
9
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-20
1
0 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__
=
"restructuredtext en"
...
...
@@ -14,14 +14,14 @@ from cubicweb import Unauthorized
from
cubicweb.selectors
import
implements
from
cubicweb.web
import
uicfg
,
box
,
action
from
cubicweb.web.htmlwidgets
import
BoxWidget
from
cubicweb.web.views
import
baseviews
from
cubicweb.web.views
import
primary
# displayed by the basket box
uicfg
.
primaryview_section
.
tag_subject_of
((
'*'
,
'in_basket'
,
'*'
),
'hidden'
)
uicfg
.
primaryview_section
.
tag_object_of
((
'*'
,
'in_basket'
,
'*'
),
'hidden'
)
class
BasketPrimaryView
(
baseviews
.
PrimaryView
):
class
BasketPrimaryView
(
primary
.
PrimaryView
):
__select__
=
implements
(
'Basket'
,)
entity_name
=
'Basket'
nothing_msg
=
_
(
'nothing in basket'
)
...
...
@@ -80,12 +80,12 @@ class BasketBox(box.UserRQLBoxTemplate):
def
selected_eids
(
self
):
selectedeids
=
()
if
self
.
rset
:
if
self
.
cw_
rset
:
# 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
.
_cw
.
vreg
.
schema
.
eschema
(
etype
).
is_
final
()
:
selectedeids
=
set
(
row
[
0
]
for
row
in
self
.
rset
.
rows
)
etype
=
iter
(
self
.
cw_
rset
.
column_types
(
0
)).
next
()
if
not
self
.
_cw
.
vreg
.
schema
.
eschema
(
etype
).
final
:
selectedeids
=
set
(
row
[
0
]
for
row
in
self
.
cw_
rset
.
rows
)
return
selectedeids
def
build_inbasket_link
(
self
,
box
,
basket
):
...
...
@@ -101,20 +101,21 @@ class BasketBox(box.UserRQLBoxTemplate):
_
(
'add to basket'
),
xml_escape
(
basket
.
name
))
linkto
=
u
'in_basket:%s:object'
%
'_'
.
join
(
addable
)
msg
=
_
(
'selection added to basket'
)
url
=
self
.
build_url
(
'edit'
,
eid
=
basket
.
eid
,
rql
=
rql
,
__linkto
=
linkto
,
__message
=
msg
,
__redirectrql
=
rql
,
__redirect_vid
=
vid
)
url
=
self
.
_cw
.
build_url
(
'edit'
,
eid
=
basket
.
eid
,
rql
=
rql
,
__linkto
=
linkto
,
__message
=
msg
,
__redirectrql
=
rql
,
__redirect_vid
=
vid
)
box
.
append
(
self
.
mk_action
(
title
,
url
,
category
=
'manage'
,
escape
=
False
))
def
build_delete_link
(
self
,
box
,
basket
,
inbasketeids
,
rql
,
vid
):
title
=
'%s <span class="basketName">%s</span>'
%
(
_
(
'reset basket'
),
xml_escape
(
basket
.
name
))
delete
=
'%s:in_basket:%s'
%
(
'_'
.
join
(
str
(
eid
)
for
eid
in
inbasketeids
),
basket
.
eid
)
msg
=
_
(
'Basket %s emptied'
)
%
basket
.
name
url
=
self
.
build_url
(
'edit'
,
rql
=
rql
,
__delete
=
delete
,
__message
=
msg
,
__redirectrql
=
rql
,
__redirect_vid
=
vid
)
url
=
self
.
_cw
.
build_url
(
'edit'
,
rql
=
rql
,
__delete
=
delete
,
__message
=
msg
,
__redirectrql
=
rql
,
__redirect_vid
=
vid
)
box
.
append
(
self
.
mk_action
(
title
,
url
,
category
=
'manage'
))
def
call
(
self
,
**
kwargs
):
...
...
@@ -125,7 +126,7 @@ class BasketBox(box.UserRQLBoxTemplate):
return
_
=
self
.
_cw
.
_
req
=
self
.
_cw
box
=
BoxWidget
(
_
(
self
.
title
),
self
.
id
)
box
=
BoxWidget
(
_
(
self
.
title
),
self
.
__regid__
)
rschema
=
self
.
_cw
.
vreg
.
schema
.
rschema
(
self
.
rtype
)
actions
=
[]
rql
=
req
.
form
.
get
(
'rql'
)
or
kwargs
.
get
(
'rql'
)
or
''
...
...
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