Commit ecceb142 authored by Klaus Wölfel's avatar Klaus Wölfel

Only add user if login does not exist yet

parent e2f70046
...@@ -61,45 +61,49 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin): ...@@ -61,45 +61,49 @@ class PersonConfiguratorItem(XMLObject, ConfiguratorItemMixin):
, PropertySheet.Login) , PropertySheet.Login)
def _checkConsistency(self, fixit=False, filter=None, **kw): def _checkConsistency(self, fixit=False, filter=None, **kw):
error_list = ["Person %s should be created" % self.getReference(),] error_list = []
if fixit: person = self.portal_catalog.getResultValue(reference=self.getReference(),
person_module = self.getPortalObject().person_module portal_type="Person")
person = person_module.newContent(portal_type="Person") if person is None:
group_id = getattr(aq_base(self), 'group_id', None) error_list.append("Person %s should be created" % self.getReference())
site_id = getattr(aq_base(self), 'site_id', None) if fixit:
person_module = self.getPortalObject().person_module
person = person_module.newContent(portal_type="Person")
group_id = getattr(aq_base(self), 'group_id', None)
site_id = getattr(aq_base(self), 'site_id', None)
if getattr(aq_base(self), 'organisation_id', None) is not None: if getattr(aq_base(self), 'organisation_id', None) is not None:
person.setCareerSubordination('organisation_module/%s' % \ person.setCareerSubordination('organisation_module/%s' % \
self.organisation_id) self.organisation_id)
# save # save
person.edit(**{'default_email_text': self.getDefaultEmailText(), person.edit(**{'default_email_text': self.getDefaultEmailText(),
'default_telephone_text': self.getDefaultTelephoneText(), 'default_telephone_text': self.getDefaultTelephoneText(),
'first_name': self.getFirstName(), 'first_name': self.getFirstName(),
'career_function': self.getFunction(), 'career_function': self.getFunction(),
'last_name': self.getLastName(), 'last_name': self.getLastName(),
'reference': self.getReference(), 'reference': self.getReference(),
'password': self.getPassword(), 'password': self.getPassword(),
}) })
assignment = person.newContent(portal_type="Assignment", assignment = person.newContent(portal_type="Assignment",
function = self.getFunction(), function = self.getFunction(),
group = group_id, group = group_id,
site = site_id) site = site_id)
# Set dates are required to create valid assigments. # Set dates are required to create valid assigments.
now = DateTime() now = DateTime()
assignment.setStartDate(now) assignment.setStartDate(now)
# XXX Is it required to set stop date? # XXX Is it required to set stop date?
# Define valid for 10 years. # Define valid for 10 years.
assignment.setStopDate(now + (365*10)) assignment.setStopDate(now + (365*10))
# Validate the Person and Assigment # Validate the Person and Assigment
person.validate(comment=translateString("Validated by Configurator")) person.validate(comment=translateString("Validated by Configurator"))
assignment.open(comment=translateString("Open by Configuration")) assignment.open(comment=translateString("Open by Configuration"))
## add to customer template ## add to customer template
business_configuration = self.getBusinessConfigurationValue() business_configuration = self.getBusinessConfigurationValue()
self.install(person, business_configuration) self.install(person, business_configuration)
return error_list return error_list
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