contact-person-profile-csv-imp-local 0.0.39__tar.gz → 0.0.40__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.39 → contact_person_profile_csv_imp_local-0.0.40}/PKG-INFO +1 -1
  2. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local/src/CSVToContactPersonProfile.py +26 -12
  3. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local.egg-info/PKG-INFO +1 -1
  4. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/setup.py +1 -1
  5. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/README.md +0 -0
  6. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local/src/__init__.py +0 -0
  7. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/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.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local.egg-info/SOURCES.txt +0 -0
  9. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local.egg-info/dependency_links.txt +0 -0
  10. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local.egg-info/requires.txt +0 -0
  11. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/contact_person_profile_csv_imp_local.egg-info/top_level.txt +0 -0
  12. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/pyproject.toml +0 -0
  13. {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.40}/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.39
3
+ Version: 0.0.40
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
@@ -173,10 +173,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
173
173
  # TODO Align the parameters between import-contact-csv with sync-google-contact
174
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?
175
175
  def insert_update_contact_from_csv(
176
+ # TODO username -> user_external_username
176
177
  self, *, username: str, email_address: str, data_source_type_id: int, file_name: str = None, system_id: int = None,
177
178
  # TODO Add support to criteria_set_id
178
179
  directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None,
179
- groups_dicts: list[dict] = None, profile_id: int = None) -> dict:
180
+ groups_dicts: list[dict] = None) -> dict:
180
181
  """
181
182
  Insert contacts from CSV file to the database
182
183
  :param data_source_type_id: The data source id
@@ -193,13 +194,15 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
193
194
  :return:
194
195
  """
195
196
  data_source_type_name = DataSources().get_data_source_name_by_id(data_source_type_id)
196
- profile_id_by_email_address = ProfilesLocal().select_one_value_by_column_and_value(
197
+ profile_id = ProfilesLocal().select_one_value_by_column_and_value(
197
198
  schema_name="profile", view_table_name="profile_view",
198
199
  select_clause_value="profile_id", column_name="profile.main_email_address",
199
200
  column_value=email_address)
201
+ if profile_id is None:
202
+ self.logger.error("Couldn't find profile_id in profile_view by email_address.")
203
+ raise Exception("Couldn't find profile_id in profile_view by email_address.")
200
204
  system_id = system_id or CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID
201
205
  self.set_schema(schema_name="field")
202
- profile_id = profile_id or profile_id_by_email_address
203
206
  self.groups_list = groups_dicts if groups_dicts else []
204
207
  '''
205
208
  profile_id = ProfilesLocal().select_one_value_by_column_and_value(
@@ -509,9 +512,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
509
512
 
510
513
  def __insert_link_contact_groups(self, contact_dict: dict) -> list:
511
514
  contact_id = contact_dict.get("contact_id")
512
- # TODO groups_dicts_list
513
- groups = []
514
- linked_groups_results_list = None
515
+ groups_dicts_list = []
516
+ linked_groups_results_list = []
515
517
  organization = contact_dict.get("organization")
516
518
  if organization:
517
519
  organization_group_dict = {
@@ -524,7 +526,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
524
526
  "is_main_title": False,
525
527
  "title": organization,
526
528
  }
527
- groups.append(organization_group_dict)
529
+ groups_dicts_list.append(organization_group_dict)
528
530
  job_title = contact_dict.get("job_title")
529
531
  if job_title:
530
532
  job_title_group_dict = {
@@ -537,7 +539,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
537
539
  "is_main_title": False,
538
540
  "title": job_title,
539
541
  }
540
- groups.append(job_title_group_dict)
542
+ groups_dicts_list.append(job_title_group_dict)
541
543
  if contact_dict.get("groups"):
542
544
  # TODO _contacts_groups_names_list?
543
545
  _groups = contact_dict.get("groups").split(", ")
@@ -552,12 +554,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
552
554
  "is_main_title": False,
553
555
  "title": group,
554
556
  }
555
- groups.append(group_dict)
557
+ groups_dicts_list.append(group_dict)
556
558
  for group in self.groups_list:
557
- groups.append(group)
558
- if len(groups) > 0:
559
+ groups_dicts_list.append(group)
560
+ if len(groups_dicts_list) > 0:
559
561
  linked_groups_results_list = self.contact_groups.insert_link_contact_group_with_group_local(
560
- contact_id=contact_id, groups_list_of_dicts=groups)
562
+ contact_id=contact_id, groups_list_of_dicts=groups_dicts_list)
561
563
  contact_dict["linked_group_results_list"] = linked_groups_results_list
562
564
 
563
565
  return linked_groups_results_list
@@ -797,6 +799,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
797
799
  proccessed_location_dicts.append(current_location_dict)
798
800
  for email_address in email_addresses_list:
799
801
  country = Country.get_country_name_by_email_address(email_address)
802
+ if country is None:
803
+ continue
800
804
  current_location_dict = {
801
805
  "address_local_language": None,
802
806
  "city": None,
@@ -866,6 +870,16 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
866
870
  user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
867
871
  select_clause_value="user_external_id", column_name="username",
868
872
  column_value=user_external_username, order_by="user_external_id DESC")
873
+ if user_external_id is None:
874
+ self.logger.error("Couldn't find user_external_id in user_external by username.")
875
+ raise Exception("Couldn't find user_external_id in user_external by username.")
876
+ # TODO: Why do we have profile_user_external schema? user_external_table already has profile_id
877
+ profile_user_external_data_dict = {"profile_id": profile_id, "user_external_id": user_external_id}
878
+ profile_user_external_id = self.insert_if_not_exists(
879
+ schema_name="profile_user_external", table_name="profile_user_external_table",
880
+ view_table_name="profile_user_external_view", data_dict=profile_user_external_data_dict,
881
+ data_dict_compare=profile_user_external_data_dict
882
+ )
869
883
 
870
884
  return user_external_id
871
885
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.39
3
+ Version: 0.0.40
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.39', # https://pypi.org/project/contact-person-profile-csv-imp-local/
8
+ version='0.0.40', # 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",