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
4af49b01a70f
Commit
751d59df
authored
Apr 30, 2009
by
sylvain.thenault@logilab.fr
Browse files
primary view refactoring and others 3.2 updates
parent
d0d2ef6d3815
Changes
1
Hide whitespace changes
Inline
Side-by-side
views.py
View file @
4af49b01
"""Specific views for baskets
:organization: Logilab
:copyright: 2003-200
8
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-200
9
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__
=
"restructuredtext en"
...
...
@@ -11,14 +11,18 @@ _ = unicode
from
logilab.mtconverter
import
html_escape
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.box
import
UserRQLBoxTemplate
from
cubicweb.web.action
import
EntityAction
from
cubicweb.web.views
import
baseviews
# displayed by the basket box
uicfg
.
rdisplay
.
tag_relation
({},
(
'*'
,
'in_basket'
,
'*'
),
'object'
)
uicfg
.
rdisplay
.
tag_relation
({},
(
'*'
,
'in_basket'
,
'*'
),
'subject'
)
class
BasketPrimaryView
(
baseviews
.
PrimaryView
):
accepts
=
(
'Basket'
,)
__select__
=
implements
(
'Basket'
,)
entity_name
=
'Basket'
nothing_msg
=
_
(
'nothing in basket'
)
content_msg
=
_
(
'items in this basket'
)
...
...
@@ -63,7 +67,7 @@ def insert_eids(actions, eids):
class
BasketBox
(
UserRQLBoxTemplate
):
class
BasketBox
(
box
.
UserRQLBoxTemplate
):
"""display a box containing all user's basketitems"""
id
=
'basket_box'
visible
=
False
# disabled by default
...
...
@@ -83,7 +87,7 @@ class BasketBox(UserRQLBoxTemplate):
if
not
self
.
schema
.
eschema
(
etype
).
is_final
():
selectedeids
=
set
(
row
[
0
]
for
row
in
self
.
rset
.
rows
)
return
selectedeids
def
build_inbasket_link
(
self
,
box
,
basket
):
rset
=
basket
.
related
(
'in_basket'
,
'object'
)
title
=
u
'%s <span class="basketName">%s</span> (%s)'
%
(
...
...
@@ -112,7 +116,7 @@ class BasketBox(UserRQLBoxTemplate):
__message
=
msg
,
__redirectrql
=
rql
,
__redirect_vid
=
vid
)
box
.
append
(
self
.
mk_action
(
title
,
url
,
category
=
'manage'
))
def
call
(
self
,
**
kwargs
):
try
:
baskets
=
self
.
req
.
execute
(
*
self
.
to_display_rql
())
...
...
@@ -135,7 +139,7 @@ class BasketBox(UserRQLBoxTemplate):
if
addable
:
self
.
build_add_link
(
box
,
basket
,
addable
,
rql
,
vid
)
if
not
rset
:
continue
continue
if
rschema
.
has_perm
(
req
,
'delete'
):
self
.
build_delete_link
(
box
,
basket
,
inbasketeids
,
rql
,
vid
)
eschema
=
self
.
schema
.
eschema
(
self
.
etype
)
...
...
@@ -146,17 +150,14 @@ class BasketBox(UserRQLBoxTemplate):
if
not
box
.
is_empty
():
box
.
render
(
self
.
w
)
# displayed by the above box
baseviews
.
PRIMARY_SKIP_RELS
.
add
(
'in_basket'
)
class
SelectBasketContentAction
(
EntityAction
):
class
SelectBasketContentAction
(
action
.
Action
):
category
=
'mainactions'
accepts
=
(
'Basket'
,
)
__select__
=
implements
(
'Basket'
)
id
=
'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
)
...
...
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