Commit 2091b80f authored by Kevin Deldycke's avatar Kevin Deldycke

In order to add Signature image on persons, Person is now a subclass of Image...

In order to add Signature image on persons, Person is now a subclass of Image and Agent not any longer.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3379 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cf248c99
...@@ -30,27 +30,26 @@ ...@@ -30,27 +30,26 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Document.Image import Image
class Agent(Image, XMLObject): class Agent(XMLObject):
""" """
An Agent is a Person who is permitted to perform some actions on the bank account according to Privileges. An Agent is a Person who is permitted to perform some actions on the bank account according to Privileges.
""" """
# CMF Type Definition # CMF Type Definition
meta_type = 'ERP5 Agent' meta_type = 'ERP5 Agent'
portal_type = 'Agent' portal_type = 'Agent'
isPortalContent = 1 isPortalContent = 1
isRADContent = 1 isRADContent = 1
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View) security.declareObjectProtected(Permissions.View)
# Default Properties # Default Properties
property_sheets = ( PropertySheet.Base property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject , PropertySheet.XMLObject
, PropertySheet.CategoryCore , PropertySheet.CategoryCore
, PropertySheet.DublinCore , PropertySheet.DublinCore
, PropertySheet.Task , PropertySheet.Task
, PropertySheet.Agent , PropertySheet.Agent
) )
...@@ -28,409 +28,357 @@ ...@@ -28,409 +28,357 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5.Core.Node import Node
from Products.ERP5.Document.Image import Image
from Products.ERP5.Document.Entity import Entity
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5Type.Utils import assertAttributePortalType from Products.ERP5Type.Utils import assertAttributePortalType
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from Products.ERP5.Core.Node import Node
from Products.ERP5.Document.Entity import Entity class Person(Entity, Node, Image, XMLObject):
"""
An Person object holds the information about
an person (ex. you, me, someone in the company,
someone outside of the company, a member of the portal,
etc.).
Person objects can contain Coordinate objects
(ex. Telephone, Url) as well a documents of various types.
Person objects can be synchronized accross multiple
sites.
Person objects inherit from the Node base class
(one of the 5 base classes in the ERP5 universal business model)
"""
meta_type = 'ERP5 Person'
portal_type = 'Person'
add_permission = Permissions.AddPortalContent
isPortalContent = 1
isRADContent = 1
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.View)
# Declarative properties
property_sheets = ( PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
, PropertySheet.DublinCore
, PropertySheet.Person)
def _setTitle(self, value):
"""
Here we see that we must define an notion
of priority in the way fields are updated
"""
if value != self.getTitle():
self.title = value
security.declareProtected(Permissions.View, 'getTitle')
def getTitle(self, **kw):
"""
Returns the title if it exists or a combination of
first name and last name
"""
if self.title == '':
name_list = []
if self.getFirstName() not in (None, ''):
name_list.append(self.getFirstName())
if self.getMiddleName() not in (None, ''):
name_list.append(self.getMiddleName())
if self.getLastName() not in (None, ''):
name_list.append(self.getLastName())
return ' '.join(name_list)
else:
return self.title
Title = getTitle
security.declareProtected(Permissions.ModifyPortalContent, 'setTitle')
def setTitle(self, value):
"""
Updates the title if necessary
"""
self._setTitle(value)
self.reindexObject()
def _setFirstName(self, value):
"""
Update Title if first_name is modified
"""
self.first_name = value
if self.getFirstName()!=None and self.getLastName()!=None:
self._setTitle(self.getFirstName()+' '+self.getLastName())
security.declareProtected(Permissions.ModifyPortalContent, 'setFirstName')
def setFirstName(self, value):
"""
Updates the first_name if necessary
"""
self._setFirstName(value)
self.reindexObject()
def _setLastName(self, value):
"""
Update Title if last_name is modified
"""
self.last_name = value
if self.getFirstName()!=None and self.getLastName()!=None:
self._setTitle(self.getFirstName()+' '+self.getLastName())
security.declareProtected(Permissions.ModifyPortalContent, 'setLastName')
def setLastName(self, value):
"""
Updates the last_name if necessary
"""
self._setLastName(value)
self.reindexObject()
security.declareProtected(Permissions.View, 'getDefaultCareerTitle')
def getDefaultCareerTitle(self):
"""
Returns the default career title
"""
try:
return self.getDefaultCareerValue().getTitle()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerDescription')
def getDefaultCareerDescription(self):
"""
Returns the default career description
"""
try:
return self.getDefaultCareerValue().getDescription()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerCollectiveAgreementTitle')
def getDefaultCareerCollectiveAgreementTitle(self):
"""
Returns the default career collective agreement
"""
try:
return self.getDefaultCareerValue().getCollectiveAgreementTitle()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerStartDate')
def getDefaultCareerStartDate(self):
"""
Returns the default career start date
"""
try:
return self.getDefaultCareerValue().getStartDate()
except:
return None
security.declareProtected(Permissions.View, 'getDefaultCareerStopDate')
def getDefaultCareerStopDate(self):
"""
Returns the default career stop date
"""
try:
return self.getDefaultCareerValue().getStopDate()
except:
return None
security.declareProtected(Permissions.View, 'getDefaultCareerSalaryLevel')
def getDefaultCareerSalaryLevel(self):
"""
Returns the default career salary level
"""
try:
return self.getDefaultCareerValue().getSalaryLevel()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerSalaryCoefficient')
def getDefaultCareerSalaryCoefficient(self):
"""
Returns the default career salary coefficient
"""
try:
return self.getDefaultCareerValue().getSalaryCoefficient()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerGrade')
def getDefaultCareerGrade(self):
"""
Returns the default career grade
"""
try:
return self.getDefaultCareerValue().getGrade()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerRole')
def getDefaultCareerRole(self):
"""
Returns the default career role
"""
try:
return self.getDefaultCareerValue().getRole()
except:
return ''
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerTitle')
def setDefaultCareerTitle(self, value):
"""
Updates the default career title
"""
self._setDefaultCareerTitle(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerDescription')
def setDefaultCareerDescription(self, value):
"""
Updates the default career description
"""
self._setDefaultCareerDescription(value)
self.reindexObject()
class Person(Entity, Node, XMLObject): security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerCollectiveAgreementTitle')
""" def setDefaultCareerCollectiveAgreementTitle(self, value):
An Person object holds the information about """
an person (ex. you, me, someone in the company, Updates the default career collective agreement
someone outside of the company, a member of the portal, """
etc.). self._setDefaultCareerCollectiveAgreementTitle(value)
self.reindexObject()
Person objects can contain Coordinate objects
(ex. Telephone, Url) as well a documents of various types. security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerStartDate')
def setDefaultCareerStartDate(self, value):
Person objects can be synchronized accross multiple """
sites. Updates the defaul career start date
"""
Person objects inherit from the Node base class self._setDefaultCareerStartDate(value)
(one of the 5 base classes in the ERP5 universal business model) self.reindexObject()
"""
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerStopDate')
meta_type = 'ERP5 Person' def setDefaultCareerStopDate(self, value):
portal_type = 'Person' """
add_permission = Permissions.AddPortalContent Updates the default career stop date
isPortalContent = 1 """
isRADContent = 1 self._setDefaultCareerStopDate(value)
self.reindexObject()
# Declarative security
security = ClassSecurityInfo() security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerSalaryLevel')
security.declareObjectProtected(Permissions.View) def setDefaultCareerSalaryLevel(self, value):
"""
# Declarative properties Updates the default career salary level
property_sheets = ( PropertySheet.Base """
, PropertySheet.XMLObject self._setDefaultCareerSalaryLevel(value)
, PropertySheet.CategoryCore self.reindexObject()
, PropertySheet.DublinCore
, PropertySheet.Person) security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerSalaryCoefficient')
def setDefaultCareerSalaryCoefficient(self, value):
# Factory Type Information """
factory_type_information = \ Updates the default career salary coefficient
{ 'id' : portal_type """
, 'meta_type' : meta_type self._setDefaultCareerSalaryCoefficient(value)
, 'description' : """\ self.reindexObject()
An Person object holds the information about
an person (ex. you, me, someone in the company, security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerGrade')
someone outside of the company, a member of the portal, def setDefaultCareerGrade(self, value):
etc.).""" """
, 'icon' : 'person_icon.gif' Updates the default career grade
, 'product' : 'ERP5' """
, 'factory' : 'addPerson' self._setDefaultCareerGrade(value)
, 'immediate_view' : 'person_edit' self.reindexObject()
, 'allow_discussion' : 1
, 'allowed_content_types': ('Assignment', 'Telephone', 'Fax', 'Bank Account', security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerRole')
'Geographic Address', 'Career' def setDefaultCareerRole(self, value):
) """
, 'filter_content_types' : 1 Updates the default career role
, 'global_allow' : 1 """
, 'actions' : self._setDefaultCareerRole(value)
( { 'id' : 'view' self.reindexObject()
, 'name' : 'View'
, 'category' : 'object_view'
, 'action' : 'person_edit' ### Private methods - no reindexing
, 'permissions' : (
Permissions.View, ) security.declarePrivate('_setDefaultCareerTitle')
} def _setDefaultCareerTitle(self, coordinate):
, { 'id' : 'print' assertAttributePortalType(self, 'default_career', 'Career')
, 'name' : 'Print' if not hasattr(self,'default_career'):
, 'category' : 'object_print' self.invokeFactory( type_name='Career'
, 'action' : 'person_print' , id='default_career'
, 'permissions' : ( )
Permissions.View, ) self.default_career.setTitle(coordinate)
}
, { 'id' : 'metadata' security.declarePrivate('_setDefaultCareerDescription')
, 'name' : 'Metadata' def _setDefaultCareerDescription(self, coordinate):
, 'category' : 'object_edit' assertAttributePortalType(self, 'default_career', 'Career')
, 'action' : 'metadata_edit' if not hasattr(self,'default_career'):
, 'permissions' : ( self.invokeFactory( type_name='Career'
Permissions.View, ) , id='default_career'
} )
, { 'id' : 'translate' self.default_career.setDescription(coordinate)
, 'name' : 'Translate'
, 'category' : 'object_action' security.declarePrivate('_setDefaultCareerCollectiveAgreementTitle')
, 'action' : 'translation_template_view' def _setDefaultCareerCollectiveAgreementTitle(self, coordinate):
, 'permissions' : ( assertAttributePortalType(self, 'default_career', 'Career')
Permissions.TranslateContent, ) if not hasattr(self,'default_career'):
} self.invokeFactory( type_name='Career'
) , id='default_career'
} )
self.default_career.setCollectiveAgreementTitle(coordinate)
def _setTitle(self, value):
""" security.declarePrivate('_setDefaultCareerStartDate')
Here we see that we must define an notion def _setDefaultCareerStartDate(self, coordinate):
of priority in the way fields are updated assertAttributePortalType(self, 'default_career', 'Career')
""" if not hasattr(self,'default_career'):
if value != self.getTitle(): self.invokeFactory( type_name='Career'
self.title = value , id='default_career'
)
security.declareProtected(Permissions.View, 'getTitle') self.default_career.setStartDate(coordinate)
def getTitle(self, **kw):
""" security.declarePrivate('_setDefaultCareerStopDate')
Returns the title if it exists or a combination of def _setDefaultCareerStopDate(self, coordinate):
first name and last name assertAttributePortalType(self, 'default_career', 'Career')
""" if not hasattr(self,'default_career'):
if self.title == '': self.invokeFactory( type_name='Career'
name_list = [] , id='default_career'
if self.getFirstName() not in (None, ''): )
name_list.append(self.getFirstName()) self.default_career.setStopDate(coordinate)
if self.getMiddleName() not in (None, ''):
name_list.append(self.getMiddleName()) security.declarePrivate('_setDefaultCareerSalaryLevel')
if self.getLastName() not in (None, ''): def _setDefaultCareerSalaryLevel(self, coordinate):
name_list.append(self.getLastName()) assertAttributePortalType(self, 'default_career', 'Career')
return ' '.join(name_list) if not hasattr(self,'default_career'):
else: self.invokeFactory( type_name='Career'
return self.title , id='default_career'
Title = getTitle )
self.default_career.setSalaryLevel(coordinate)
security.declareProtected(Permissions.ModifyPortalContent, 'setTitle')
def setTitle(self, value): security.declarePrivate('_setDefaultCareerSalaryCoefficient')
""" def _setDefaultCareerSalaryCoefficient(self, coordinate):
Updates the title if necessary assertAttributePortalType(self, 'default_career', 'Career')
""" if not hasattr(self,'default_career'):
self._setTitle(value) self.invokeFactory( type_name='Career'
self.reindexObject() , id='default_career'
)
def _setFirstName(self, value): self.default_career.setSalaryCoefficient(coordinate)
"""
Update Title if first_name is modified security.declarePrivate('_setDefaultCareerGrade')
""" def _setDefaultCareerGrade(self, coordinate):
self.first_name = value assertAttributePortalType(self, 'default_career', 'Career')
if self.getFirstName()!=None and self.getLastName()!=None: if not hasattr(self,'default_career'):
self._setTitle(self.getFirstName()+' '+self.getLastName()) self.invokeFactory( type_name='Career'
, id='default_career'
security.declareProtected(Permissions.ModifyPortalContent, 'setFirstName') )
def setFirstName(self, value): self.default_career.setGrade(coordinate)
"""
Updates the first_name if necessary security.declarePrivate('_setDefaultCareerRole')
""" def _setDefaultCareerRole(self, coordinate):
self._setFirstName(value) assertAttributePortalType(self, 'default_career', 'Career')
self.reindexObject() if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
def _setLastName(self, value): , id='default_career'
""" )
Update Title if last_name is modified self.default_career.setRole(coordinate)
""" \ No newline at end of file
self.last_name = value
if self.getFirstName()!=None and self.getLastName()!=None:
self._setTitle(self.getFirstName()+' '+self.getLastName())
security.declareProtected(Permissions.ModifyPortalContent, 'setLastName')
def setLastName(self, value):
"""
Updates the last_name if necessary
"""
self._setLastName(value)
self.reindexObject()
security.declareProtected(Permissions.View, 'getDefaultCareerTitle')
def getDefaultCareerTitle(self):
"""
Returns the default career title
"""
try:
return self.getDefaultCareerValue().getTitle()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerDescription')
def getDefaultCareerDescription(self):
"""
Returns the default career description
"""
try:
return self.getDefaultCareerValue().getDescription()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerCollectiveAgreementTitle')
def getDefaultCareerCollectiveAgreementTitle(self):
"""
Returns the default career collective agreement
"""
try:
return self.getDefaultCareerValue().getCollectiveAgreementTitle()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerStartDate')
def getDefaultCareerStartDate(self):
"""
Returns the default career start date
"""
try:
return self.getDefaultCareerValue().getStartDate()
except:
return None
security.declareProtected(Permissions.View, 'getDefaultCareerStopDate')
def getDefaultCareerStopDate(self):
"""
Returns the default career stop date
"""
try:
return self.getDefaultCareerValue().getStopDate()
except:
return None
security.declareProtected(Permissions.View, 'getDefaultCareerSalaryLevel')
def getDefaultCareerSalaryLevel(self):
"""
Returns the default career salary level
"""
try:
return self.getDefaultCareerValue().getSalaryLevel()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerSalaryCoefficient')
def getDefaultCareerSalaryCoefficient(self):
"""
Returns the default career salary coefficient
"""
try:
return self.getDefaultCareerValue().getSalaryCoefficient()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerGrade')
def getDefaultCareerGrade(self):
"""
Returns the default career grade
"""
try:
return self.getDefaultCareerValue().getGrade()
except:
return ''
security.declareProtected(Permissions.View, 'getDefaultCareerRole')
def getDefaultCareerRole(self):
"""
Returns the default career role
"""
try:
return self.getDefaultCareerValue().getRole()
except:
return ''
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerTitle')
def setDefaultCareerTitle(self, value):
"""
Updates the default career title
"""
self._setDefaultCareerTitle(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerDescription')
def setDefaultCareerDescription(self, value):
"""
Updates the default career description
"""
self._setDefaultCareerDescription(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerCollectiveAgreementTitle')
def setDefaultCareerCollectiveAgreementTitle(self, value):
"""
Updates the default career collective agreement
"""
self._setDefaultCareerCollectiveAgreementTitle(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerStartDate')
def setDefaultCareerStartDate(self, value):
"""
Updates the defaul career start date
"""
self._setDefaultCareerStartDate(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerStopDate')
def setDefaultCareerStopDate(self, value):
"""
Updates the default career stop date
"""
self._setDefaultCareerStopDate(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerSalaryLevel')
def setDefaultCareerSalaryLevel(self, value):
"""
Updates the default career salary level
"""
self._setDefaultCareerSalaryLevel(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerSalaryCoefficient')
def setDefaultCareerSalaryCoefficient(self, value):
"""
Updates the default career salary coefficient
"""
self._setDefaultCareerSalaryCoefficient(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerGrade')
def setDefaultCareerGrade(self, value):
"""
Updates the default career grade
"""
self._setDefaultCareerGrade(value)
self.reindexObject()
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultCareerRole')
def setDefaultCareerRole(self, value):
"""
Updates the default career role
"""
self._setDefaultCareerRole(value)
self.reindexObject()
### Private methods - no reindexing
security.declarePrivate('_setDefaultCareerTitle')
def _setDefaultCareerTitle(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setTitle(coordinate)
security.declarePrivate('_setDefaultCareerDescription')
def _setDefaultCareerDescription(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setDescription(coordinate)
security.declarePrivate('_setDefaultCareerCollectiveAgreementTitle')
def _setDefaultCareerCollectiveAgreementTitle(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setCollectiveAgreementTitle(coordinate)
security.declarePrivate('_setDefaultCareerStartDate')
def _setDefaultCareerStartDate(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setStartDate(coordinate)
security.declarePrivate('_setDefaultCareerStopDate')
def _setDefaultCareerStopDate(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setStopDate(coordinate)
security.declarePrivate('_setDefaultCareerSalaryLevel')
def _setDefaultCareerSalaryLevel(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setSalaryLevel(coordinate)
security.declarePrivate('_setDefaultCareerSalaryCoefficient')
def _setDefaultCareerSalaryCoefficient(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setSalaryCoefficient(coordinate)
security.declarePrivate('_setDefaultCareerGrade')
def _setDefaultCareerGrade(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setGrade(coordinate)
security.declarePrivate('_setDefaultCareerRole')
def _setDefaultCareerRole(self, coordinate):
assertAttributePortalType(self, 'default_career', 'Career')
if not hasattr(self,'default_career'):
self.invokeFactory( type_name='Career'
, id='default_career'
)
self.default_career.setRole(coordinate)
\ No newline at end of file
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