Commit d53eb267 authored by Jean-Paul Smets's avatar Jean-Paul Smets Committed by Xiaowu Zhang

Remove hardcoded value

Use request (populated by site template) or current context to determine the web site. Also cleaned some comments and docstrings.
parent 4d524da9
......@@ -55,12 +55,20 @@
needed to provide a default price for a given resource\n
\n
TODO:\n
- support input parameters (**kw) to specialize\n
price calculation\n
- add support to input parameters (**kw) so that it\n
is possible specialize price calculation\n
"""\n
from Products.ERP5Type.Document import newTempMovement\n
\n
web_site_value = context.getPortalObject().web_site_module.weinparis # hack cause no way to know default site....\n
# Try to find out the current web site\n
web_site_value = context.REQUEST.get(\'current_web_site\', None)\n
if web_site_value is None:\n
web_site_value = context.getWebSiteValue() \n
if web_site_value is None:\n
raise ValueError("Could not determine the current web site to compute default currency of price")\n
\n
# If this resource is variated, initialize the default\n
# variation context\n
variation_dict = {}\n
if len(context.getVariationRangeCategoryList()):\n
request = context.REQUEST\n
......@@ -75,6 +83,7 @@ if len(context.getVariationRangeCategoryList()):\n
default_variation = default_variation[0]\n
variation_category = request.get(variation_base_category, default_variation)\n
variation_dict[variation_base_category] = variation_category\n
\n
movement = newTempMovement(context, "temp_pricing_movement", resource_value=context,\n
price_currency_value=web_site_value.WebSite_getShoppingCartDefaultCurrency(),\n
**variation_dict)\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment