Commit f90a08d0 authored by Aurel's avatar Aurel

budget cell : some more fixes thanks to julien

define security on the right class
use newstyle class so that slots is effective
cleanup whitespace and indentation
parent 8b5b8ae9
...@@ -36,7 +36,8 @@ from Products.ERP5.mixin.variated import VariatedMixin ...@@ -36,7 +36,8 @@ from Products.ERP5.mixin.variated import VariatedMixin
from Products.ERP5Type.Cache import transactional_cached from Products.ERP5Type.Cache import transactional_cached
from ZTUtils import make_query from ZTUtils import make_query
class TempBudgetCell: class TempBudgetCell(object):
__allow_access_to_unprotected_subobjects__ = 1
__slots__ = ('amount', 'cell_index', 'url', 'engaged_budget') __slots__ = ('amount', 'cell_index', 'url', 'engaged_budget')
def __init__(self, amount, cell_index, url, engaged_budget): def __init__(self, amount, cell_index, url, engaged_budget):
self.amount = amount self.amount = amount
...@@ -48,15 +49,15 @@ class TempBudgetCell: ...@@ -48,15 +49,15 @@ class TempBudgetCell:
return self.amount return self.amount
def getAvailableBudget(self): def getAvailableBudget(self):
return self.amount return self.amount
def getEngagedBudget(self): def getEngagedBudget(self):
return self.amount return self.amount
def getExplanationUrl(self, *args, **w): def getExplanationUrl(self, *args, **w):
return '%s/BudgetLine_viewConsumedBudgetMovementList?%s' % ( return '%s/BudgetLine_viewConsumedBudgetMovementList?%s' % (
self.url, self.url,
make_query(dict(cell_index=list(self.cell_index), engaged_budget=self.engaged_budget))) make_query(dict(cell_index=list(self.cell_index), engaged_budget=self.engaged_budget)))
class BudgetLine(Predicate, XMLMatrix, VariatedMixin): class BudgetLine(Predicate, XMLMatrix, VariatedMixin):
...@@ -82,7 +83,6 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin): ...@@ -82,7 +83,6 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin):
meta_type='ERP5 Budget Line' meta_type='ERP5 Budget Line'
portal_type='Budget Line' portal_type='Budget Line'
add_permission = Permissions.AddPortalContent add_permission = Permissions.AddPortalContent
__allow_access_to_unprotected_subobjects__ = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
...@@ -165,19 +165,19 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin): ...@@ -165,19 +165,19 @@ class BudgetLine(Predicate, XMLMatrix, VariatedMixin):
'getConsumedBudgetCell') 'getConsumedBudgetCell')
def getConsumedBudgetCell(self, *cell_index, **kw): def getConsumedBudgetCell(self, *cell_index, **kw):
consumed_budget_dict = self.getConsumedBudgetDict() consumed_budget_dict = self.getConsumedBudgetDict()
return TempBudgetCell(consumed_budget_dict.get(cell_index), return TempBudgetCell(consumed_budget_dict.get(cell_index),
cell_index, self.absolute_url(), False) cell_index, self.absolute_url(), False)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableBudgetCell') 'getAvailableBudgetCell')
def getAvailableBudgetCell(self, *cell_index, **kw): def getAvailableBudgetCell(self, *cell_index, **kw):
available_budget_dict = self.getAvailableBudgetDict() available_budget_dict = self.getAvailableBudgetDict()
return TempBudgetCell(available_budget_dict.get(cell_index), return TempBudgetCell(available_budget_dict.get(cell_index),
cell_index, self.absolute_url(), True) cell_index, self.absolute_url(), True)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getEngagedBudgetCell') 'getEngagedBudgetCell')
def getEngagedBudgetCell(self, *cell_index, **kw): def getEngagedBudgetCell(self, *cell_index, **kw):
engaged_budget_dict = self.getEngagedBudgetDict() engaged_budget_dict = self.getEngagedBudgetDict()
return TempBudgetCell(engaged_budget_dict.get(cell_index), return TempBudgetCell(engaged_budget_dict.get(cell_index),
cell_index, self.absolute_url(), True) cell_index, self.absolute_url(), True)
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