Skip to content
Snippets Groups Projects
Commit 06c8982e authored by Robert Latta's avatar Robert Latta
Browse files

updated to build organisation as users from different source

parent 299201d7
No related branches found
No related tags found
No related merge requests found
...@@ -141,9 +141,8 @@ def otrs_get_customer_users_rows(ds): ...@@ -141,9 +141,8 @@ def otrs_get_customer_users_rows(ds):
# TODO - check the rules for validation once model has been confirmed # TODO - check the rules for validation once model has been confirmed
def _is_valid_customer(cus): def _is_valid_customer(cus):
# commented out as no contact details are in IMS if not cus['email']:
# if not cus['email']: return False
# return False
return True return True
# TODO - check this rule for getting the customer_id2 once model has been confirmed # noqa # TODO - check this rule for getting the customer_id2 once model has been confirmed # noqa
...@@ -158,30 +157,38 @@ def otrs_get_customer_users_rows(ds): ...@@ -158,30 +157,38 @@ def otrs_get_customer_users_rows(ds):
ims.CUSTOMER_PROPERTIES['CustomerRelatedContacts'], ims.CUSTOMER_PROPERTIES['CustomerRelatedContacts'],
ims.CUSTOMER_PROPERTIES['CustomerType'] ims.CUSTOMER_PROPERTIES['CustomerType']
]): ]):
# Org as User # # Org as User
org_customer = OrderedDict({ # org_customer = OrderedDict({
'type': customer['CustomerType']['Name'] if customer[ # 'type': customer['CustomerType']['Name'] if customer[
'CustomerType'] else '', # 'CustomerType'] else '',
'email': customer['AccountEmail'], # 'email': customer['AccountEmail'],
'username': customer['AccountEmail'], # 'username': customer['AccountEmail'],
'customer_id': customer['Name'], # 'customer_id': customer['Name'],
'customer_id_2': _get_customer_id2(customer), # 'customer_id_2': _get_customer_id2(customer),
'title': '', # 'title': '',
'firstname': customer['Name'], # 'firstname': customer['Name'],
'lastname': '-', # 'lastname': '-',
'phone': '', # 'phone': '',
'fax': '', # 'fax': '',
'mobile': '', # 'mobile': '',
'street': '', # 'street': '',
'zip': '', # 'zip': '',
'city': '', # 'city': '',
'country': '', # 'country': '',
'comments': '' # 'comments': 'Organisation imported as a user'
}) # })
if _is_valid_customer(org_customer): # if _is_valid_customer(org_customer):
del org_customer['type'] # del org_customer['type']
yield org_customer.values() #
# end of Org as User # # todo - remove from here after testing
# # dummy_email = f'dumy_{dummy_counter}@geant.org'
# # org_customer['email'] = dummy_email
# # org_customer['username'] = dummy_email
# # dummy_counter += 1
# # todo - remove up to here after testing
#
# yield list(org_customer.values())
# # end of Org as User
# Contacts as Users # Contacts as Users
if customer['CustomerRelatedContacts']: if customer['CustomerRelatedContacts']:
...@@ -198,7 +205,11 @@ def otrs_get_customer_users_rows(ds): ...@@ -198,7 +205,11 @@ def otrs_get_customer_users_rows(ds):
'customer_id_2': _get_customer_id2(customer), 'customer_id_2': _get_customer_id2(customer),
'title': '', 'title': '',
'firstname': contact['Contact']['Name'], 'firstname': contact['Contact']['Name'],
'lastname': contact['Contact']['LastName'], 'lastname':
' '.join(filter(None, [
contact['Contact']['InFix'],
contact['Contact']['LastName']
])),
'phone': '', 'phone': '',
'fax': '', 'fax': '',
'mobile': '', 'mobile': '',
...@@ -210,13 +221,15 @@ def otrs_get_customer_users_rows(ds): ...@@ -210,13 +221,15 @@ def otrs_get_customer_users_rows(ds):
}) })
if not _is_valid_customer(t_customer_user): if not _is_valid_customer(t_customer_user):
continue continue
customer_user = _choose_customer_user( if contact['Contact']['IsGroup']:
t_customer_user, t_customer_user['comments'] = \
customer_user 'Organisation imported as a user'
)
if customer_user: del t_customer_user['type']
del customer_user['type'] yield list(t_customer_user.values())
yield customer_user.values() # if customer_user:
# del customer_user['type']
# yield list(customer_user.values())
# end of Contact as User # end of Contact as User
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment