contact-person-profile-csv-imp-local 0.0.33__tar.gz → 0.0.35__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (13) hide show
  1. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/PKG-INFO +1 -1
  2. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local/src/CSVToContactPersonProfile.py +55 -30
  3. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local/src/contact_person_profile_csv_imp_local_constants.py +6 -0
  4. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local.egg-info/PKG-INFO +1 -1
  5. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/setup.py +1 -1
  6. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/README.md +0 -0
  7. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local/src/__init__.py +0 -0
  8. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local.egg-info/SOURCES.txt +0 -0
  9. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local.egg-info/dependency_links.txt +0 -0
  10. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local.egg-info/requires.txt +0 -0
  11. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/contact_person_profile_csv_imp_local.egg-info/top_level.txt +0 -0
  12. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/pyproject.toml +0 -0
  13. {contact_person_profile_csv_imp_local-0.0.33 → contact_person_profile_csv_imp_local-0.0.35}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python
5
5
  Home-page: https://github.com/circles-zone/contact-person-profile-csv-imp-local-python-package
6
6
  Author: Circles
@@ -46,8 +46,6 @@ CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID = 1
46
46
  DEFAULT_LOCATION_ID = LocationLocalConstants.UNKNOWN_LOCATION_ID
47
47
  DEFAULT_PROFILE_ID = 0
48
48
 
49
- RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID = 60
50
-
51
49
 
52
50
  # Those methods should be called from the common method for this repo (contact-person-profile-csv-imp-local-python-package and google-contact-sync ...)
53
51
 
@@ -132,6 +130,16 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
132
130
  self.importers_local = ImportersLocal()
133
131
  self.data_sources = DataSources()
134
132
  self.groups_list = None
133
+ self.unknown_main_group_type_id = self.select_one_value_by_column_and_value(
134
+ schema_name='group', view_table_name='group_type_ml_view',
135
+ select_clause_value='group_type_id', column_name='title', column_value='Unknown')
136
+ self.organization_main_group_type_id = self.select_one_value_by_column_and_value(
137
+ schema_name='group', view_table_name='group_type_ml_view',
138
+ select_clause_value='group_type_id', column_name='title', column_value='Organization')
139
+ self.job_title_main_group_type_id = self.select_one_value_by_column_and_value(
140
+ schema_name='group', view_table_name='group_type_ml_view',
141
+ select_clause_value='group_type_id', column_name='title', column_value='Job Title')
142
+
135
143
 
136
144
  # # TODO Does this function should be here on in https://github.com/circles-zone/variable-local-python-package/tree/dev/variable_local_python_package/variable_local/src "field/field.py"?
137
145
  # def __get_field_name(self, field_id: int, data_source_type_id: int) -> str:
@@ -165,26 +173,36 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
165
173
  # TODO Align the parameters between import-contact-csv with sync-google-contact
166
174
  # TODO Can we please add groups_str parameter to both sync-google-contact and import-contact-csv where we add all contacts to those groups?
167
175
  def insert_update_contact_from_csv(
168
- self, *, data_source_type_id: int, file_name: str = None, user_external_username: str, system_id: int = None,
176
+ self, *, data_source_type_name: str, file_name: str = None, user_external_username: str, system_name: str = None,
169
177
  # TODO Add support to criteria_set_id
170
178
  directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None,
171
- groups_dicts: dict = None, profile_id: int = None) -> dict:
179
+ groups_dicts: list[dict] = None, profile_id: int = None) -> dict:
172
180
  """
173
181
  Insert contacts from CSV file to the database
174
- :param data_source_type_id: The data source ID
182
+ :param data_source_type_name: The data source name
175
183
  :param file_name: The CSV file name
176
184
  :param user_external_username: The user external username
185
+ :param system_name: The system name
186
+ :param user_external_username: The user external username
187
+ :param groups_dicts: The groups list
188
+ :param profile_id: The profile ID
177
189
  :param directory_name: The CSV file directory name if it wasn't given it will search for the file in the same directory
178
190
  :param csv_path: The CSV file path if it wasn't given it will search for the file in the same directory
179
191
  :param start_index: The start index
180
192
  :param end_index: The end index
181
193
  :return:
182
194
  """
183
-
195
+ data_source_type_id = DataSources().get_data_source_type_id_by_name(data_source_type_name)
184
196
  profile_id_by_email_address = ProfilesLocal().select_one_value_by_column_and_value(
185
197
  schema_name="profile", view_table_name="profile_view",
186
198
  select_clause_value="profile_id", column_name="profile.main_email_address",
187
199
  column_value=user_external_username)
200
+ system_id = CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID
201
+ if system_name:
202
+ system_id = self.select_one_value_by_column_and_value(
203
+ schema_name="system", view_table_name="system_ml_view",
204
+ select_clause_value="system_id", column_name="title", column_value=system_name)
205
+ self.set_schema(schema_name="field")
188
206
  profile_id = profile_id or profile_id_by_email_address
189
207
  self.groups_list = groups_dicts if groups_dicts else []
190
208
  '''
@@ -202,7 +220,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
202
220
  csv_file_path = csv_path
203
221
  else:
204
222
  script_dir = os.path.dirname(os.path.abspath(__file__))
205
- csv_file_path = os.path.join(script_dir, '..', 'tests', directory_name or '', file_name)
223
+ csv_file_path = os.path.join(script_dir, '..', directory_name or '', file_name)
206
224
  if not os.path.exists(csv_file_path):
207
225
  raise FileNotFoundError(f"File {csv_file_path} not found")
208
226
 
@@ -215,7 +233,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
215
233
  'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
216
234
  'address2_country', 'job_title', 'organization', 'display_as')
217
235
 
218
- user_external_id = self.__get_user_external_id(user_external_username=user_external_username, profile_id=profile_id)
236
+ user_external_id = self.__get_user_external_id(user_external_username=user_external_username,
237
+ profile_id=profile_id, system_id=system_id)
219
238
  # We create a new data_source_instance_id everytime we import a new csv file
220
239
  data_source_instance_id = self.__get_data_source_instance_id(
221
240
  data_source_type_id=data_source_type_id, csv_file_path=csv_file_path,
@@ -288,8 +307,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
288
307
  # contact_dict['last_name'] = process_last_name(
289
308
  # original_last_name=contact_dict['last_name'])
290
309
 
291
- # TODO This should be executed also by Google Contact Sync (please make sure it is in people-local-python-package
292
- # i.e. get_display_name(first_name, last_name, organization) -> str
310
+ # TODO This should be executed also by Google Contact Sync (please make sure it is in
311
+ # people-local-python-package i.e. get_display_name(first_name, last_name, organization) -> str
293
312
  if contact_dict.get('display_as') is None:
294
313
  contact_dict['display_as'] = contact_dict.get(
295
314
  'first_name') or "" # prevent None
@@ -306,11 +325,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
306
325
  # TODO We should take care of situation which the contact already exists and we need to update it
307
326
  contact_dict["data_source_instance_id"] = data_source_instance_id
308
327
  contact_dict["data_source_type_id"] = data_source_type_id
309
- contact_dict["source"] = "Import"
328
+ contact_dict["source"] = data_source_type_name
310
329
  contact_dict["owner_profile_id"] = profile_id
311
330
  contact_dict["system_id"] = system_id
312
331
  contact_dict = CSVToContactPersonProfile.fix_contact_dict_by_data_source_type(
313
- contact_dict=contact_dict, data_source_type_id=data_source_type_id)
332
+ contact_dict=contact_dict)
314
333
  contact_id = self.contacts_local.upsert_contact_dict(contact_dict=contact_dict)
315
334
  contact_dict["contact_id"] = contact_id
316
335
  if contact_id:
@@ -432,7 +451,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
432
451
  contact_id=contact_dict.get("contact_id"), location_id=contact_dict.get("location_id") or DEFAULT_LOCATION_ID,
433
452
  user_external_id=user_external_id,
434
453
  data_source_instance_id=data_source_instance_id,
435
- data_source_type_id=data_source_type_id
454
+ data_source_type_id=data_source_type_id,
455
+ data_source_type_name=contact_dict.get("source")
436
456
  )
437
457
  return importer_id
438
458
 
@@ -500,11 +520,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
500
520
  organization = contact_dict.get("organization")
501
521
  if organization:
502
522
  organization_group_dict = {
523
+ # table:
503
524
  "name": organization,
504
525
  "hashtag": '#' + organization.upper(),
505
526
  "is_organization": 1,
506
- "main_group_type_id": 2000, # TODO: Shall we get it from db or from constant?
507
- # ml table
527
+ "main_group_type_id": self.organization_main_group_type_id,
528
+ # ml table:
508
529
  "is_main_title": False,
509
530
  "title": organization,
510
531
  }
@@ -512,11 +533,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
512
533
  job_title = contact_dict.get("job_title")
513
534
  if job_title:
514
535
  job_title_group_dict = {
536
+ # table:
515
537
  "name": job_title,
516
538
  "hashtag": '#' + job_title.upper(),
517
539
  "is_job_title": 1,
518
- "main_group_type_id": 3001, # TODO: Shall we get it from db or from constant?
519
- # ml table
540
+ "main_group_type_id": self.job_title_main_group_type_id,
541
+ # ml table:
520
542
  "is_main_title": False,
521
543
  "title": job_title,
522
544
  }
@@ -525,10 +547,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
525
547
  _groups = contact_dict.get("groups").split(", ")
526
548
  for group in _groups:
527
549
  group_dict = {
550
+ # table:
528
551
  "name": group,
529
552
  "hashtag": '#' + group.upper(),
530
- "main_group_type_id": 0, # TODO: Shall we get it from db or from constant?
531
- # ml table
553
+ "main_group_type_id": self.unknown_main_group_type_id,
554
+ # ml table:
532
555
  "is_main_title": False,
533
556
  "title:": group,
534
557
  }
@@ -605,6 +628,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
605
628
  contact_dict=contact_dict,
606
629
  contact_email_address=contact_dict["email1"],
607
630
  contact_id=contact_id,
631
+ system_id=contact_dict.get("system_id"),
608
632
  user_external_dict={"username": contact_dict["email1"]}
609
633
  )
610
634
 
@@ -651,18 +675,19 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
651
675
 
652
676
  # TODO merge this method with the method in google-contact-sync
653
677
  def __insert_importer(self, contact_id: int, location_id: int, user_external_id: int,
654
- data_source_type_id: int, data_source_instance_id: int) -> int:
678
+ data_source_type_id: int, data_source_instance_id: int,
679
+ data_source_type_name: str) -> int:
655
680
  # TODO: Shall we consider the url of csv's as the following? Use Sql2Code. Use const enum
656
- if data_source_type_id == 16:
681
+ if data_source_type_name == CSVToContactPersonProfileConstants.GOOGLE_CSV_DATA_SOURCE_TYPE_NAME:
657
682
  url = "www.google.com"
658
- elif data_source_type_id == 17:
683
+ elif data_source_type_name == CSVToContactPersonProfileConstants.OUTLOOK_CSV_DATA_SOURCE_TYPE_NAME:
659
684
  url = "www.outlook.com"
660
- elif data_source_type_id == 18:
685
+ elif data_source_type_name == CSVToContactPersonProfileConstants.LINKEDIN_CSV_DATA_SOURCE_TYPE_NAME:
661
686
  url = "www.linkedin.com"
662
687
  # TODO Please change all Magic Numbers to data generated by Sql2Code
663
- elif data_source_type_id == 57: # BGU Course csv
688
+ elif data_source_type_name == CSVToContactPersonProfileConstants.BGU_COURSE_CSV_DATA_SOURCE_TYPE_NAME:
664
689
  url = None
665
- elif data_source_type_id == RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
690
+ elif data_source_type_name == CSVToContactPersonProfileConstants.RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_NAME:
666
691
  url = None
667
692
  else:
668
693
  raise ValueError("data_source_type_id is not valid")
@@ -813,7 +838,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
813
838
  # TODO use enum const for "email1" ....
814
839
  return emails_list
815
840
 
816
- def __get_user_external_id(self, user_external_username: str, profile_id: int) -> int or None:
841
+ def __get_user_external_id(self, user_external_username: str, profile_id: int, system_id: int) -> int or None:
817
842
 
818
843
  user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
819
844
  select_clause_value="user_external_id", column_name="username",
@@ -822,7 +847,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
822
847
  self.user_externals_local.insert_or_update_user_external_access_token(
823
848
  username=user_external_username,
824
849
  profile_id=profile_id,
825
- system_id=CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID,
850
+ system_id=system_id,
826
851
  access_token=""
827
852
  )
828
853
  user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
@@ -866,11 +891,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
866
891
  return result['encoding']
867
892
 
868
893
  @staticmethod
869
- def fix_contact_dict_by_data_source_type(contact_dict: dict, data_source_type_id: int) -> dict:
870
- if data_source_type_id == RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
894
+ def fix_contact_dict_by_data_source_type(contact_dict: dict) -> dict:
895
+ if contact_dict.get('source') == CSVToContactPersonProfileConstants.RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_NAME:
871
896
  if contact_dict.get('phone1'):
872
897
  cellphone_number = contact_dict.get('phone1')
873
898
  if cellphone_number.startswith('0'):
874
899
  cellphone_number = '+972 ' + cellphone_number
875
900
  contact_dict['phone1'] = cellphone_number
876
- return contact_dict
901
+ return contact_dict
@@ -19,3 +19,9 @@ class CSVToContactPersonProfileConstants:
19
19
  'testing_framework': LoggerComponentEnum.testingFramework.pytest.value,
20
20
  'developer_email': DEVELOPER_EMAIL
21
21
  }
22
+
23
+ GOOGLE_CSV_DATA_SOURCE_TYPE_NAME = 'Google Contact CSV File'
24
+ LINKEDIN_CSV_DATA_SOURCE_TYPE_NAME = 'Linkedin Contact CSV File'
25
+ OUTLOOK_CSV_DATA_SOURCE_TYPE_NAME = 'Outlook Contact CSV File'
26
+ BGU_COURSE_CSV_DATA_SOURCE_TYPE_NAME = 'BGU Course CSV File'
27
+ RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_NAME = 'Rishon Muni Exhibitor CSV File'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python
5
5
  Home-page: https://github.com/circles-zone/contact-person-profile-csv-imp-local-python-package
6
6
  Author: Circles
@@ -5,7 +5,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
5
5
 
6
6
  setuptools.setup(
7
7
  name=PACKAGE_NAME,
8
- version='0.0.33', # https://pypi.org/project/contact-person-profile-csv-imp-local/
8
+ version='0.0.35', # https://pypi.org/project/contact-person-profile-csv-imp-local/
9
9
  author="Circles",
10
10
  author_email="info@circles.ai",
11
11
  description="PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python",