contact-person-profile-csv-imp-local 0.0.29__py3-none-any.whl → 0.0.30__py3-none-any.whl
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.
- contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py +15 -7
- {contact_person_profile_csv_imp_local-0.0.29.dist-info → contact_person_profile_csv_imp_local-0.0.30.dist-info}/METADATA +1 -1
- {contact_person_profile_csv_imp_local-0.0.29.dist-info → contact_person_profile_csv_imp_local-0.0.30.dist-info}/RECORD +5 -5
- {contact_person_profile_csv_imp_local-0.0.29.dist-info → contact_person_profile_csv_imp_local-0.0.30.dist-info}/WHEEL +0 -0
- {contact_person_profile_csv_imp_local-0.0.29.dist-info → contact_person_profile_csv_imp_local-0.0.30.dist-info}/top_level.txt +0 -0
|
@@ -19,6 +19,7 @@ from importer_local.ImportersLocal import ImportersLocal
|
|
|
19
19
|
from database_mysql_local.point import Point
|
|
20
20
|
from database_mysql_local.generic_crud import GenericCRUD
|
|
21
21
|
from contact_user_external_local.contact_user_external_local import ContactUserExternalLocal
|
|
22
|
+
from profile_local.profiles_local import ProfilesLocal
|
|
22
23
|
from contact_profile_local.contact_profiles_local import ContactProfilesLocal
|
|
23
24
|
from contact_phone_local.contact_phone_local import ContactPhoneLocal
|
|
24
25
|
from phones_local.phones_local import PhonesLocal
|
|
@@ -160,7 +161,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
160
161
|
# TODO Align the parameters between import-contact-csv with sync-google-contact
|
|
161
162
|
# 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?
|
|
162
163
|
def insert_update_contact_from_csv(
|
|
163
|
-
self, *, data_source_type_id: int, file_name: str = None, user_external_username: str,
|
|
164
|
+
self, *, data_source_type_id: int, file_name: str = None, user_external_username: str, system_id: int = None,
|
|
164
165
|
# TODO Add support to criteria_set_id
|
|
165
166
|
directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None) -> dict:
|
|
166
167
|
"""
|
|
@@ -174,7 +175,10 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
174
175
|
:param end_index: The end index
|
|
175
176
|
:return:
|
|
176
177
|
"""
|
|
177
|
-
|
|
178
|
+
profile_id = ProfilesLocal().select_one_value_by_column_and_value(
|
|
179
|
+
schema_name="profile", view_table_name="profile_view",
|
|
180
|
+
select_clause_value="profile_id", column_name="profile_main_email",
|
|
181
|
+
column_value=user_external_username)
|
|
178
182
|
# TODO Please explain
|
|
179
183
|
# if csv_path is provided then we will use the full path
|
|
180
184
|
# if csv_path is not provided then we will use the directory_name and file_name to create the full path
|
|
@@ -191,12 +195,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
191
195
|
contact_fields_to_keep = (
|
|
192
196
|
'name_prefix', 'additional_name', 'name_suffix', 'nickname', 'full_name', 'title', 'department', 'notes',
|
|
193
197
|
'first_name', 'last_name', 'phone1', 'phone2', 'phone3', 'birthday', 'email1', 'email2', 'email3',
|
|
194
|
-
'hashtag', 'url', 'groups',
|
|
198
|
+
'hashtag', 'url', 'groups', 'added_timestamp',
|
|
195
199
|
'website1', 'handle', 'address1_street', 'address1_city', 'address1_state', 'address1_postal_code',
|
|
196
200
|
'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
|
|
197
201
|
'address2_country', 'job_title', 'organization', 'display_as')
|
|
198
202
|
|
|
199
|
-
user_external_id = self.__get_user_external_id(user_external_username)
|
|
203
|
+
user_external_id = self.__get_user_external_id(user_external_username=user_external_username, profile_id=profile_id)
|
|
200
204
|
# We create a new data_source_instance_id everytime we import a new csv file
|
|
201
205
|
data_source_instance_id = self.__get_data_source_instance_id(
|
|
202
206
|
data_source_type_id=data_source_type_id, csv_file_path=csv_file_path,
|
|
@@ -205,6 +209,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
205
209
|
start_index=start_index, end_index=end_index
|
|
206
210
|
)
|
|
207
211
|
fields_dictonary = self.data_sources.get_fields_name_from_csv(data_source_type_id)
|
|
212
|
+
self.logger.info(f"fields_dictonary: {fields_dictonary}")
|
|
208
213
|
keys = list(fields_dictonary.keys())
|
|
209
214
|
contact_data_by_contact_id_dict = {}
|
|
210
215
|
encoding = CSVToContactPersonProfile.detect_encoding(file_path=csv_file_path, data_source_type_id=data_source_type_id)
|
|
@@ -245,6 +250,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
245
250
|
|
|
246
251
|
contact_dict = {key: contact_dict.get(
|
|
247
252
|
key) or None for key in contact_fields_to_keep}
|
|
253
|
+
self.logger.info(f"contact_dict: {contact_dict}")
|
|
248
254
|
if (not contact_dict.get('first_name')
|
|
249
255
|
and not contact_dict.get('last_name')
|
|
250
256
|
and not contact_dict.get('organization')):
|
|
@@ -284,8 +290,10 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
284
290
|
|
|
285
291
|
# TODO We should take care of situation which the contact already exists and we need to update it
|
|
286
292
|
contact_dict["data_source_instance_id"] = data_source_instance_id
|
|
293
|
+
contact_dict["data_source_type_id"] = data_source_type_id
|
|
287
294
|
contact_dict["source"] = "Import"
|
|
288
|
-
contact_dict["owner_profile_id"] =
|
|
295
|
+
contact_dict["owner_profile_id"] = profile_id
|
|
296
|
+
contact_dict["system_id"] = system_id
|
|
289
297
|
contact_id = self.contacts_local.upsert_contact_dict(contact_dict=contact_dict)
|
|
290
298
|
contact_dict["contact_id"] = contact_id
|
|
291
299
|
if contact_id:
|
|
@@ -747,7 +755,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
747
755
|
# TODO use enum const for "email1" ....
|
|
748
756
|
return emails_list
|
|
749
757
|
|
|
750
|
-
def __get_user_external_id(self, user_external_username: str) -> int or None:
|
|
758
|
+
def __get_user_external_id(self, user_external_username: str, profile_id: int) -> int or None:
|
|
751
759
|
|
|
752
760
|
user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
|
|
753
761
|
select_clause_value="user_external_id", column_name="username",
|
|
@@ -755,7 +763,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
755
763
|
if user_external_id is None:
|
|
756
764
|
self.user_externals_local.insert_or_update_user_external_access_token(
|
|
757
765
|
username=user_external_username,
|
|
758
|
-
profile_id=
|
|
766
|
+
profile_id=profile_id,
|
|
759
767
|
system_id=CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID,
|
|
760
768
|
access_token=""
|
|
761
769
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: contact-person-profile-csv-imp-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.30
|
|
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py,sha256=
|
|
1
|
+
contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py,sha256=PyxEVut4mNat6KEkWs7N8p8cnvSZR4plprBUi-hws_c,44312
|
|
2
2
|
contact_person_profile_csv_imp_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
contact_person_profile_csv_imp_local/contact_person_profile_csv_imp_local_constants.py,sha256=eE0Bg2dCPrmG72K20k0_KOckc61C9cGSgH0Zgae_lbk,957
|
|
4
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
5
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
6
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
7
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
4
|
+
contact_person_profile_csv_imp_local-0.0.30.dist-info/METADATA,sha256=EEJl_VnhaKYKRdo4v7_Y_tkZYzEVrdcZhIzxaDW47-o,1481
|
|
5
|
+
contact_person_profile_csv_imp_local-0.0.30.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
6
|
+
contact_person_profile_csv_imp_local-0.0.30.dist-info/top_level.txt,sha256=at6BnVzULDB109KZx9Cl9ClCHU4c0ykfV38WX-QR71U,37
|
|
7
|
+
contact_person_profile_csv_imp_local-0.0.30.dist-info/RECORD,,
|
|
File without changes
|