Commit 01bb7f08 authored by Romain Courteaud's avatar Romain Courteaud

Remove workflow methods validate and invalidate.

Modify code layout.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3957 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 00c1215f
...@@ -485,22 +485,6 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -485,22 +485,6 @@ class Resource(XMLMatrix, CoreResource, Variated):
# # Do nothing by default # # Do nothing by default
# pass # pass
security.declareProtected( Permissions.ModifyPortalContent, 'validate' )
def validate(self):
"""
"""
pass
validate = WorkflowMethod( validate )
security.declareProtected( Permissions.ModifyPortalContent, 'invalidate' )
def invalidate(self):
"""
"""
pass
invalidate = WorkflowMethod( invalidate )
# Predicate handling # Predicate handling
security.declareProtected(Permissions.AccessContentsInformation, 'asPredicate') security.declareProtected(Permissions.AccessContentsInformation, 'asPredicate')
def asPredicate(self): def asPredicate(self):
...@@ -513,10 +497,13 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -513,10 +497,13 @@ class Resource(XMLMatrix, CoreResource, Variated):
p.setMembershipCriterionCategoryList(('resource/%s' % self.getRelativeUrl(),)) p.setMembershipCriterionCategoryList(('resource/%s' % self.getRelativeUrl(),))
return p return p
security.declareProtected(Permissions.AccessContentsInformation, 'getPrice') security.declareProtected(Permissions.AccessContentsInformation,
'getPrice')
def getPrice(self, context=None, REQUEST=None, **kw): def getPrice(self, context=None, REQUEST=None, **kw):
""" """
Return the unit price of a resource in a specific context.
""" """
# Search all categories context
new_category_list = [] new_category_list = []
if context is not None: if context is not None:
new_category_list += context.getCategoryList() new_category_list += context.getCategoryList()
...@@ -525,30 +512,27 @@ class Resource(XMLMatrix, CoreResource, Variated): ...@@ -525,30 +512,27 @@ class Resource(XMLMatrix, CoreResource, Variated):
del kw['categories'] del kw['categories']
resource_category = 'resource/' + self.getRelativeUrl() resource_category = 'resource/' + self.getRelativeUrl()
if not resource_category in new_category_list: if not resource_category in new_category_list:
new_category_list += (resource_category,) new_category_list += (resource_category, )
# Generate the fake context
tmp_context = self.asContext(context=context, tmp_context = self.asContext(context=context,
categories=new_category_list, categories=new_category_list,
REQUEST=REQUEST, **kw) REQUEST=REQUEST, **kw)
# Generate the predicate mapped value
# to get some price values.
domain_tool = getToolByName(self,'portal_domains') domain_tool = getToolByName(self,'portal_domains')
portal_type_list = self.getPortalSupplyTypeList() portal_type_list = self.getPortalSupplyTypeList()
mapped_value = domain_tool.generateMappedValue(tmp_context, mapped_value = domain_tool.generateMappedValue(
portal_type=portal_type_list, tmp_context,
has_cell_content=0,**kw) portal_type=portal_type_list,
base_price = None has_cell_content=0, **kw)
# Calculate the unit price
unit_base_price = None
if mapped_value is not None: if mapped_value is not None:
base_price = mapped_value.getBasePrice() base_price = mapped_value.getBasePrice()
if base_price in [None, '']:
unit_base_price = None base_price = self.getBasePrice()
if base_price in [None,'']: if base_price not in [None, '']:
base_price = self.getBasePrice()
if base_price is not None:
priced_quantity = self.getPricedQuantity() priced_quantity = self.getPricedQuantity()
unit_base_price = base_price / priced_quantity unit_base_price = base_price / priced_quantity
else: # Return result
priced_quantity = self.getPricedQuantity() return unit_base_price
unit_base_price = base_price / priced_quantity
return unit_base_price
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