tgshops-integrations 2.1__py3-none-any.whl → 2.3__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.
- tgshops_integrations/nocodb_connector/products.py +22 -9
- {tgshops_integrations-2.1.dist-info → tgshops_integrations-2.3.dist-info}/METADATA +1 -1
- {tgshops_integrations-2.1.dist-info → tgshops_integrations-2.3.dist-info}/RECORD +5 -5
- {tgshops_integrations-2.1.dist-info → tgshops_integrations-2.3.dist-info}/WHEEL +0 -0
- {tgshops_integrations-2.1.dist-info → tgshops_integrations-2.3.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@ from tgshops_integrations.models.products import ProductModel, ProductModel
|
|
6
6
|
from tgshops_integrations.nocodb_connector.client import custom_key_builder, NocodbClient
|
7
7
|
from tgshops_integrations.nocodb_connector.model_mapping import dump_product_data,dump_product_data_with_check, get_pagination_info, ID_FIELD, \
|
8
8
|
parse_product_data, PRODUCT_CATEGORY_ID_LOOKUP_FIELD, PRODUCT_NAME_FIELD, PRODUCT_PRICE_FIELD, \
|
9
|
-
PRODUCT_STOCK_FIELD
|
9
|
+
PRODUCT_STOCK_FIELD,PRODUCT_EXTERNAL_ID,PRODUCT_IMAGES_LOOKUP_FIELD
|
10
10
|
|
11
11
|
from tgshops_integrations.nocodb_connector.tables import *
|
12
12
|
from loguru import logger
|
@@ -15,25 +15,27 @@ import hashlib
|
|
15
15
|
|
16
16
|
class ProductManager(NocodbClient):
|
17
17
|
|
18
|
-
def __init__(self,table_id=None,logging=False,NOCODB_HOST=None,NOCODB_API_KEY=None,SOURCE=None):
|
19
|
-
super().__init__(NOCODB_HOST=NOCODB_HOST,NOCODB_API_KEY=NOCODB_API_KEY,SOURCE=SOURCE)
|
18
|
+
def __init__(self, table_id=None, logging=False, NOCODB_HOST=None, NOCODB_API_KEY=None, SOURCE=None):
|
19
|
+
super().__init__(NOCODB_HOST=NOCODB_HOST, NOCODB_API_KEY=NOCODB_API_KEY, SOURCE=SOURCE)
|
20
20
|
self.NOCODB_HOST = NOCODB_HOST
|
21
21
|
self.NOCODB_API_KEY = NOCODB_API_KEY
|
22
|
-
self.SOURCE=SOURCE
|
23
|
-
self.logging=logging
|
22
|
+
self.SOURCE = SOURCE
|
23
|
+
self.logging = logging
|
24
24
|
self.required_fields = [PRODUCT_NAME_FIELD, PRODUCT_PRICE_FIELD]
|
25
25
|
self.projection = []
|
26
|
-
self.external_categories={}
|
27
|
-
self.products_table=table_id
|
28
|
-
self.actual_products=[]
|
29
|
-
self.columns=[]
|
26
|
+
self.external_categories = {}
|
27
|
+
self.products_table = table_id
|
28
|
+
self.actual_products = []
|
29
|
+
self.columns = []
|
30
30
|
|
31
31
|
def hash_product(self,product,special_attributes=False):
|
32
32
|
if special_attributes:
|
33
33
|
hash_string = ''.join(attr.description for attr in product.extra_attributes if attr.name.endswith('*'))
|
34
|
+
# hash_string = f"{product.external_id}{product.price}{product.category_name.sort()}{product.name}{product.description}"
|
34
35
|
else:
|
35
36
|
# Concatenate relevant attributes into a single string
|
36
37
|
hash_string = f"{product.external_id}{product.price}{product.category_name.sort()}{product.name}{product.description}"
|
38
|
+
# hash_string = f"{product.external_id}{product.price}{product.category_name}{product.name}{product.description}{product.preview_url}"
|
37
39
|
# Hash the concatenated string
|
38
40
|
hash_object = hashlib.sha256(hash_string.encode())
|
39
41
|
hex_dig = hash_object.hexdigest()
|
@@ -152,9 +154,20 @@ class ProductManager(NocodbClient):
|
|
152
154
|
|
153
155
|
@cached(ttl=60, key_builder=custom_key_builder)
|
154
156
|
async def update_attributes(self,products:List[ProductModel]):
|
157
|
+
system_attributes = [PRODUCT_EXTERNAL_ID,PRODUCT_IMAGES_LOOKUP_FIELD]
|
158
|
+
attributes=await self.get_table_meta(table_name=self.products_table)
|
159
|
+
self.columns =[item['title'].lower() for item in attributes.get('columns', [])]
|
160
|
+
|
161
|
+
#TODO Requires Validation
|
162
|
+
for attribute_name in system_attributes:
|
163
|
+
if attribute_name.lower() not in self.columns:
|
164
|
+
response =await self.create_table_column(table_name=self.products_table,name=attribute_name)
|
165
|
+
logger.info(f"Created attribute: {attribute_name}")
|
166
|
+
|
155
167
|
for item in products:
|
156
168
|
attributes=await self.get_table_meta(table_name=self.products_table)
|
157
169
|
self.columns =[item['title'].lower() for item in attributes.get('columns', [])]
|
170
|
+
|
158
171
|
for attribute in item.extra_attributes:
|
159
172
|
if attribute.name.rstrip().lower() not in self.columns:
|
160
173
|
response =await self.create_table_column(table_name=self.products_table,name=attribute.name.lower())
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tgshops-integrations
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.3
|
4
4
|
Summary: Library is intended to provide the integration of the external service or CRM system with the TelegramShops/It allows to configure the relationship between NocoDB list of the products used further to display in the shop/As a resultss the products can be synchronized and updated uppon the request.
|
5
5
|
Home-page: https://git.the-devs.com/virtual-shops/shop-system/shop-backend-integrations/integration-library/integration-library
|
6
6
|
Author: Dimi Latoff
|
@@ -8,9 +8,9 @@ tgshops_integrations/nocodb_connector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCe
|
|
8
8
|
tgshops_integrations/nocodb_connector/categories.py,sha256=x9mtXYEEIt6jV1Qzh_hYwKYJjqyuWyopmyeV0V4myUQ,9069
|
9
9
|
tgshops_integrations/nocodb_connector/client.py,sha256=RD8UDS4AXrN1GFmjakZsdTGbP_u2bsoxfopq7UV6MT0,11725
|
10
10
|
tgshops_integrations/nocodb_connector/model_mapping.py,sha256=nsul7OjUHgGhpV-iwwaAvb9SnBlwj4evHDcXSd-v1zk,8919
|
11
|
-
tgshops_integrations/nocodb_connector/products.py,sha256=
|
11
|
+
tgshops_integrations/nocodb_connector/products.py,sha256=kAp7lUaRO7CkU_SumbIdLOJf38SmDBEyBBZCYyyyOFM,9313
|
12
12
|
tgshops_integrations/nocodb_connector/tables.py,sha256=ha_QXZXd93mht0fR5E1nM0wUpz1ePon-pIdO2HI67l8,356
|
13
|
-
tgshops_integrations-2.
|
14
|
-
tgshops_integrations-2.
|
15
|
-
tgshops_integrations-2.
|
16
|
-
tgshops_integrations-2.
|
13
|
+
tgshops_integrations-2.3.dist-info/METADATA,sha256=LOfmK4AlpRP8RaaENwFerCWIMIPkElHuwv_mSUZiZpo,2774
|
14
|
+
tgshops_integrations-2.3.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
15
|
+
tgshops_integrations-2.3.dist-info/top_level.txt,sha256=HFNtxqDpzmlF4ZLnMiwhbU7pOa_YozxU2zBl0bnUmcY,21
|
16
|
+
tgshops_integrations-2.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|