contact-person-profile-csv-imp-local 0.0.31__tar.gz → 0.0.32__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.31 → contact_person_profile_csv_imp_local-0.0.32}/PKG-INFO +1 -1
  2. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local/src/CSVToContactPersonProfile.py +73 -18
  3. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local.egg-info/PKG-INFO +1 -1
  4. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/setup.py +1 -1
  5. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/README.md +0 -0
  6. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local/src/__init__.py +0 -0
  7. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local/src/contact_person_profile_csv_imp_local_constants.py +0 -0
  8. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local.egg-info/SOURCES.txt +0 -0
  9. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local.egg-info/dependency_links.txt +0 -0
  10. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local.egg-info/requires.txt +0 -0
  11. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/contact_person_profile_csv_imp_local.egg-info/top_level.txt +0 -0
  12. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/pyproject.toml +0 -0
  13. {contact_person_profile_csv_imp_local-0.0.31 → contact_person_profile_csv_imp_local-0.0.32}/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.31
3
+ Version: 0.0.32
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,6 +46,8 @@ 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
+
49
51
 
50
52
  # Those methods should be called from the common method for this repo (contact-person-profile-csv-imp-local-python-package and google-contact-sync ...)
51
53
 
@@ -105,6 +107,7 @@ DEFAULT_PROFILE_ID = 0
105
107
 
106
108
  class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
107
109
  object=CSVToContactPersonProfileConstants.CSV_LOCAL_PYTHON_PACKAGE_CODE_LOGGER_OBJECT):
110
+ # TODO Shall we have the groups_str parameter in the constructor or when running the each import so we can use different groups_str for every import
108
111
  def __init__(self, groups_str: str = None, is_test_data: bool = False) -> None:
109
112
  GenericCRUD.__init__(self, default_schema_name="field", default_column_name="field_id",
110
113
  default_table_name="field_table", default_view_table_name="field_view",
@@ -165,7 +168,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
165
168
  self, *, data_source_type_id: int, file_name: str = None, user_external_username: str, system_id: int = None,
166
169
  # TODO Add support to criteria_set_id
167
170
  directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None,
168
- groups_str: str = None, profile_id: int = None) -> dict:
171
+ groups_dicts: dict = None, profile_id: int = None) -> dict:
169
172
  """
170
173
  Insert contacts from CSV file to the database
171
174
  :param data_source_type_id: The data source ID
@@ -177,14 +180,13 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
177
180
  :param end_index: The end index
178
181
  :return:
179
182
  """
180
- '''
183
+
181
184
  profile_id_by_email_address = ProfilesLocal().select_one_value_by_column_and_value(
182
185
  schema_name="profile", view_table_name="profile_view",
183
186
  select_clause_value="profile_id", column_name="profile.main_email_address",
184
187
  column_value=user_external_username)
185
- '''
186
- profile_id = profile_id or self.user_context.get_effective_profile_id()
187
- self.groups_list = [group.strip() for group in groups_str.split(",")] if groups_str else []
188
+ profile_id = profile_id or profile_id_by_email_address
189
+ self.groups_list = groups_dicts if groups_dicts else []
188
190
  '''
189
191
  profile_id = ProfilesLocal().select_one_value_by_column_and_value(
190
192
  schema_name="profile", view_table_name="profile_view",
@@ -208,7 +210,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
208
210
  contact_fields_to_keep = (
209
211
  'name_prefix', 'additional_name', 'name_suffix', 'nickname', 'full_name', 'title', 'department', 'notes',
210
212
  'first_name', 'last_name', 'phone1', 'phone2', 'phone3', 'birthday', 'email1', 'email2', 'email3',
211
- 'hashtag', 'url', 'groups', 'added_timestamp',
213
+ 'hashtag', 'url', 'groups', 'added_timestamp', 'comment',
212
214
  'website1', 'handle', 'address1_street', 'address1_city', 'address1_state', 'address1_postal_code',
213
215
  'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
214
216
  'address2_country', 'job_title', 'organization', 'display_as')
@@ -307,6 +309,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
307
309
  contact_dict["source"] = "Import"
308
310
  contact_dict["owner_profile_id"] = profile_id
309
311
  contact_dict["system_id"] = system_id
312
+ contact_dict = CSVToContactPersonProfile.fix_contact_dict_by_data_source_type(
313
+ contact_dict=contact_dict, data_source_type_id=data_source_type_id)
310
314
  contact_id = self.contacts_local.upsert_contact_dict(contact_dict=contact_dict)
311
315
  contact_dict["contact_id"] = contact_id
312
316
  if contact_id:
@@ -323,7 +327,6 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
323
327
 
324
328
  # TODO def insert_update_contact_groups_from_contact_notes( contact_notes: str) -> int:
325
329
  # TODO Add contact_group with seq, attribute, is_sure using group-local-python-package
326
-
327
330
  # TODO def process_people_url( people_url ) -> str:
328
331
  # TODO Use regex to extract the data from the URL
329
332
  # TODO add to user_external using user-external-python-package
@@ -494,19 +497,47 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
494
497
  contact_id = contact_dict.get("contact_id")
495
498
  groups = []
496
499
  groups_linked = None
497
- if contact_dict.get("organization"):
498
- groups.append(contact_dict.get("organization"))
499
- if contact_dict.get("job_title"):
500
- groups.append(contact_dict.get("job_title"))
500
+ organization = contact_dict.get("organization")
501
+ if organization:
502
+ organization_group_dict = {
503
+ "name": organization,
504
+ "hashtag": '#' + organization.upper(),
505
+ "is_organization": 1,
506
+ "main_group_type_id": 2000, # TODO: Shall we get it from db or from constant?
507
+ # ml table
508
+ "is_main_title": False,
509
+ "title": organization,
510
+ }
511
+ groups.append(organization_group_dict)
512
+ job_title = contact_dict.get("job_title")
513
+ if job_title:
514
+ job_title_group_dict = {
515
+ "name": job_title,
516
+ "hashtag": '#' + job_title.upper(),
517
+ "is_job_title": 1,
518
+ "main_group_type_id": 3001, # TODO: Shall we get it from db or from constant?
519
+ # ml table
520
+ "is_main_title": False,
521
+ "title": job_title,
522
+ }
523
+ groups.append(job_title_group_dict)
501
524
  if contact_dict.get("groups"):
502
525
  _groups = contact_dict.get("groups").split(", ")
503
526
  for group in _groups:
504
- groups.append(group)
527
+ group_dict = {
528
+ "name": group,
529
+ "hashtag": '#' + group.upper(),
530
+ "main_group_type_id": 0, # TODO: Shall we get it from db or from constant?
531
+ # ml table
532
+ "is_main_title": False,
533
+ "title:": group,
534
+ }
535
+ groups.append(group_dict)
505
536
  for group in self.groups_list:
506
537
  groups.append(group)
507
538
  if len(groups) > 0:
508
539
  groups_linked = self.contact_groups.insert_link_contact_group_with_group_local(
509
- contact_id=contact_id, groups_names=groups)
540
+ contact_id=contact_id, groups_dicts=groups)
510
541
 
511
542
  return groups_linked
512
543
 
@@ -631,6 +662,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
631
662
  # TODO Please change all Magic Numbers to data generated by Sql2Code
632
663
  elif data_source_type_id == 57: # BGU Course csv
633
664
  url = None
665
+ elif data_source_type_id == RISHON_MUNI_EXHIBITOR_CSV_DATA_SOURCE_TYPE_ID:
666
+ url = None
634
667
  else:
635
668
  raise ValueError("data_source_type_id is not valid")
636
669
  importer_id = self.importers_local.insert(
@@ -706,7 +739,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
706
739
  self.logger.error("Error while getting country name by phone number",
707
740
  object=exception)
708
741
  continue
709
- currect_location_dict = {
742
+ current_location_dict = {
710
743
  "address_local_language": None,
711
744
  "city": None,
712
745
  "postal_code": None,
@@ -717,10 +750,16 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
717
750
  "state": LocationLocalConstants.DEFAULT_STATE_NAME,
718
751
  "region": LocationLocalConstants.DEFAULT_REGION_NAME,
719
752
  }
720
- proccessed_location_dicts.append(currect_location_dict)
753
+ # Before adding the location to the list, check if it's country is not already in the list
754
+ for location_dict in proccessed_location_dicts:
755
+ if location_dict.get("country") == current_location_dict.get("country"):
756
+ current_location_dict = None
757
+ break
758
+ if current_location_dict:
759
+ proccessed_location_dicts.append(current_location_dict)
721
760
  for email_address in email_addresses_list:
722
761
  country = Country.get_country_name_by_email_address(email_address)
723
- currect_location_dict = {
762
+ current_location_dict = {
724
763
  "address_local_language": None,
725
764
  "city": None,
726
765
  "postal_code": None,
@@ -731,7 +770,13 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
731
770
  "state": LocationLocalConstants.DEFAULT_STATE_NAME,
732
771
  "region": LocationLocalConstants.DEFAULT_REGION_NAME,
733
772
  }
734
- proccessed_location_dicts.append(currect_location_dict)
773
+ # Before adding the location to the list, check if it's country is not already in the list
774
+ for location_dict in proccessed_location_dicts:
775
+ if location_dict.get("country") == current_location_dict.get("country"):
776
+ current_location_dict = None
777
+ break
778
+ if current_location_dict:
779
+ proccessed_location_dicts.append(current_location_dict)
735
780
 
736
781
  return proccessed_location_dicts
737
782
 
@@ -813,9 +858,19 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
813
858
  @staticmethod
814
859
  # TODO Move this function to python-sdk
815
860
  def detect_encoding(file_path: str, data_source_type_id: int = None):
816
- if data_source_type_id == 16 or data_source_type_id == 17 or data_source_type_id == 18:
861
+ if data_source_type_id in [16, 17, 18]:
817
862
  return "utf-8"
818
863
  else:
819
864
  with open(file_path, 'rb') as f:
820
865
  result = chardet.detect(f.read())
821
866
  return result['encoding']
867
+
868
+ @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:
871
+ if contact_dict.get('phone1'):
872
+ cellphone_number = contact_dict.get('phone1')
873
+ if cellphone_number.startswith('0'):
874
+ cellphone_number = '+972 ' + cellphone_number
875
+ contact_dict['phone1'] = cellphone_number
876
+ return contact_dict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.31
3
+ Version: 0.0.32
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.31', # https://pypi.org/project/contact-person-profile-csv-imp-local/
8
+ version='0.0.32', # 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",