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
cmt
Commits
45eaed43cc38
Commit
48cd73d1
authored
Aug 09, 2011
by
Nicolas Chauvat
Browse files
[schema views] add billing address (closes #1908592)
parent
b283546140ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
__pkginfo__.py
View file @
45eaed43
...
...
@@ -4,7 +4,7 @@
modname
=
'cmt'
distname
=
'cubicweb-cmt'
numversion
=
(
0
,
4
,
0
)
numversion
=
(
0
,
5
,
0
)
version
=
'.'
.
join
(
str
(
num
)
for
num
in
numversion
)
license
=
'LCL'
...
...
migration/0.5.0_Any.py
0 → 100644
View file @
45eaed43
add_entity_type
(
'BillingAddress'
)
schema.py
View file @
45eaed43
...
...
@@ -17,9 +17,10 @@
"""cubicweb-cmt schema"""
from
yams.buildobjs
import
RelationDefinition
from
yams.buildobjs
import
RelationDefinition
,
EntityType
,
String
from
cubes.shoppingcart.schema
import
ShoppingItem
from
cubes.conference.schema
import
user_owns_subject
,
user_owns_object
ShoppingItem
.
get_relation
(
'quantity'
).
default
=
1
...
...
@@ -32,3 +33,22 @@ class has_shoppingitemtype(RelationDefinition):
subject
=
'Conference'
object
=
'ShoppingItemType'
cardinality
=
'*1'
class
BillingAddress
(
EntityType
):
organisation
=
String
(
required
=
True
,
maxsize
=
256
)
street
=
String
(
required
=
True
,
maxsize
=
256
)
street2
=
String
(
required
=
True
,
maxsize
=
256
)
postalcode
=
String
(
required
=
True
,
maxsize
=
256
)
city
=
String
(
required
=
True
,
maxsize
=
256
)
country
=
String
(
required
=
True
,
maxsize
=
256
)
your_ref
=
String
(
maxsize
=
256
)
class
billing
(
RelationDefinition
):
__permissions__
=
{
'read'
:
(
'managers'
,
'users'
),
'add'
:
(
'managers'
,
user_owns_subject
()),
'delete'
:
(
'managers'
,
user_owns_subject
()),
}
subject
=
'ShoppingCart'
object
=
'BillingAddress'
cardinality
=
'?1'
views.py
View file @
45eaed43
...
...
@@ -24,7 +24,7 @@ from cubicweb.selectors import (is_instance, match_view, match_context,
authenticated_user
)
from
cubicweb.web
import
uicfg
,
Redirect
,
component
from
cubicweb.web.component
import
Layout
from
cubicweb.web.views
import
primary
from
cubes.conference.views.startup
import
ConferenceIndexView
from
cubes.conference.views.forms
import
subject_reg_open_conf_vocabulary
...
...
@@ -34,6 +34,9 @@ from cubes.shoppingcart.views import ShoppingCartEntityFormRenderer
uicfg
.
autoform_field_kwargs
.
tag_subject_of
((
'ShoppingCart'
,
'book_conf'
,
'Conference'
),
{
'choices'
:
subject_reg_open_conf_vocabulary
})
uicfg
.
actionbox_appearsin_addmenu
.
tag_subject_of
((
'Conference'
,
'has_shoppingitemtype'
,
'*'
),
True
)
uicfg
.
actionbox_appearsin_addmenu
.
tag_subject_of
((
'ShoppingCart'
,
'billing'
,
'*'
),
True
)
uicfg
.
primaryview_section
.
tag_subject_of
((
'ShoppingCart'
,
'billing'
,
'*'
),
'hidden'
)
uicfg
.
primaryview_section
.
tag_object_of
((
'ShoppingCart'
,
'billing'
,
'BillingAddress'
),
'hidden'
)
_
=
unicode
...
...
@@ -180,11 +183,37 @@ class CmtShoppingCartPrimaryView(ShoppingCartPrimaryView):
self
.
w
(
u
'</p>'
)
self
.
w
(
btn_modify
)
else
:
conf
=
entity
.
book_conf
[
0
]
self
.
w
(
u
'<p><a href="%s">%s</a></p>'
%
(
conf
.
absolute_url
(),
self
.
_cw
.
_
(
'Go to the conference schedule'
)))
if
entity
.
billing
:
self
.
w
(
u
'<p>%s</p>'
%
self
.
_cw
.
_
(
'Billing address'
))
entity
.
billing
[
0
].
view
(
'primary'
,
w
=
self
.
w
)
else
:
add_url
=
self
.
_cw
.
build_url
(
'add/BillingAddress'
,
__linkto
=
'billing:%d:object'
%
entity
.
eid
,
__redirectpath
=
'shoppingcart/%d'
%
entity
.
eid
,
__redirectvid
=
'primary'
)
self
.
w
(
u
'<p><a href="%s">%s</a></p>'
%
(
xml_escape
(
add_url
),
self
.
_cw
.
_
(
'Add a billing address'
)))
self
.
w
(
u
'<hr /><p><a href="%s">%s</a></p>'
%
(
entity
.
book_conf
[
0
].
absolute_url
(),
self
.
_cw
.
_
(
'Go to the conference schedule'
)))
REPLACE_LIST
.
append
((
CmtShoppingCartPrimaryView
,
ShoppingCartPrimaryView
))
# XXX move this upstream into cw
def
set_field_order
(
etype
,
attrs
):
for
index
,
attr
in
enumerate
(
attrs
):
uicfg
.
autoform_field_kwargs
.
tag_subject_of
(
(
etype
,
attr
,
'*'
),
{
'order'
:
index
})
uicfg
.
primaryview_display_ctrl
.
tag_subject_of
(
(
etype
,
attr
,
'*'
),
{
'order'
:
index
})
set_field_order
(
'BillingAddress'
,
(
'organisation'
,
'street'
,
'street2'
,
'postalcode'
,
'city'
,
'country'
,
'your_ref'
,))
class
BillingAddressPrimaryView
(
primary
.
PrimaryView
):
__select__
=
primary
.
PrimaryView
.
__select__
&
is_instance
(
'BillingAddress'
)
def
render_entity_title
(
self
,
entity
):
pass
# registration view
class
ConfRegistrationView
(
EntityView
):
__regid__
=
'conf-registration'
...
...
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