tgshops-integrations 3.8__tar.gz → 4.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/PKG-INFO +1 -1
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/setup.py +1 -1
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/middlewares/gateway.py +1 -2
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/nocodb_connector/categories_management.py +30 -17
- tgshops_integrations-3.8/tgshops_integrations/nocodb_connector/products_management.py → tgshops_integrations-4.0/tgshops_integrations/nocodb_connector/products_management.py.py +10 -10
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/PKG-INFO +1 -1
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/SOURCES.txt +1 -1
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/README.md +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/setup.cfg +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/__init__.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/middlewares/__init__.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/models/__init__.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/models/categories.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/models/products.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/nocodb_connector/__init__.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/nocodb_connector/client.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/nocodb_connector/model_mapping.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/nocodb_connector/tables.py +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/dependency_links.txt +0 -0
- {tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tgshops_integrations
|
3
|
-
Version:
|
3
|
+
Version: 4.0
|
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
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/middlewares/gateway.py
RENAMED
@@ -27,7 +27,6 @@ from tgshops_integrations.nocodb_connector.categories_management import Category
|
|
27
27
|
from tgshops_integrations.nocodb_connector.products_management import ProductManager
|
28
28
|
from loguru import logger
|
29
29
|
|
30
|
-
|
31
30
|
def custom_key_builder(func, *args, **kwargs):
|
32
31
|
"""
|
33
32
|
Key builder function for caching.
|
@@ -120,7 +119,7 @@ class Gateway(NocodbClient):
|
|
120
119
|
self.products_meta = {product.external_id: product for product in self.actual_products}
|
121
120
|
|
122
121
|
for product in external_products:
|
123
|
-
if product.external_id in self.ids_mapping:
|
122
|
+
if (product.external_id in self.ids_mapping and product.external_id !=''):
|
124
123
|
product.id = self.ids_mapping[product.external_id]
|
125
124
|
current_hash = self.product_manager.hash_product(product, special_attributes=self.special_attributes)
|
126
125
|
existing_hash = self.product_manager.hash_product(
|
@@ -1,10 +1,10 @@
|
|
1
1
|
from typing import List
|
2
2
|
from loguru import logger
|
3
3
|
from aiocache import cached
|
4
|
-
from
|
5
|
-
from
|
6
|
-
from
|
7
|
-
from
|
4
|
+
from models.categories import CategoryModel, CategoryResponseModel, CategoryListResponseModel
|
5
|
+
from models.products import ProductModel
|
6
|
+
from services.nocodb_connector.client import custom_key_builder, NocodbClient
|
7
|
+
from services.nocodb_connector.model_mapping import (
|
8
8
|
CATEGORY_IMAGE_FIELD,
|
9
9
|
CATEGORY_NAME_FIELD,
|
10
10
|
CATEGORY_PARENT_FIELD,
|
@@ -83,23 +83,34 @@ class CategoryManager(NocodbClient):
|
|
83
83
|
)
|
84
84
|
return [parse_category_data(record) for record in records]
|
85
85
|
|
86
|
-
async def update_categories(self, external_products: List[ProductModel]) -> None:
|
86
|
+
async def update_categories(self, external_products: List[ProductModel],with_properties: bool = False) -> None:
|
87
87
|
self.categories = await self.get_product_categories(table_id=self.categories_table, table_name=PRODUCT_NAME_FIELD)
|
88
88
|
categories_list = list(self.categories.keys())
|
89
89
|
properties_to_create = []
|
90
|
+
parent_id=0
|
90
91
|
|
91
|
-
|
92
|
-
for
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
92
|
+
if with_properties:
|
93
|
+
for product in external_products:
|
94
|
+
for num, product_property in enumerate(product.product_properties[:len(self.filter_buttons)]):
|
95
|
+
if product_property not in categories_list:
|
96
|
+
# TODO: Needs restructuring
|
97
|
+
# parent_id = (
|
98
|
+
# self.categories[self.filter_buttons[num]]
|
99
|
+
# if self.filter_buttons
|
100
|
+
# else self.categories[product.category_I_name[0]]
|
101
|
+
# )
|
102
|
+
|
103
|
+
properties_to_create.append([product_property, parent_id])
|
104
|
+
categories_list.append(product_property)
|
105
|
+
|
106
|
+
else:
|
107
|
+
for product in external_products:
|
108
|
+
# for item in product.categories_structure.values():
|
109
|
+
# if item not in categories_list:
|
110
|
+
for product_property in product.product_properties:
|
111
|
+
if product_property not in categories_list:
|
112
|
+
properties_to_create.append([product_property, parent_id])
|
113
|
+
categories_list.append(product_property)
|
103
114
|
|
104
115
|
if properties_to_create:
|
105
116
|
properties_to_create.sort(key=lambda x: x[0])
|
@@ -115,6 +126,8 @@ class CategoryManager(NocodbClient):
|
|
115
126
|
if self.logging:
|
116
127
|
logger.info(f"New Category: {new_property}")
|
117
128
|
new_id += 1
|
129
|
+
|
130
|
+
self.categories = await self.get_product_categories(table_id=self.categories_table, table_name=PRODUCT_NAME_FIELD)
|
118
131
|
|
119
132
|
async def link_categories(self, parent_id: int, child_id: int):
|
120
133
|
metadata = await self.get_table_meta(self.categories_table)
|
@@ -18,7 +18,6 @@ from tgshops_integrations.nocodb_connector.model_mapping import (
|
|
18
18
|
PRODUCT_IMAGES_LOOKUP_FIELD,
|
19
19
|
)
|
20
20
|
|
21
|
-
|
22
21
|
class ProductManager(NocodbClient):
|
23
22
|
def __init__(self, table_id=None, logging=False, NOCODB_HOST=None, NOCODB_API_KEY=None, SOURCE=None):
|
24
23
|
super().__init__(NOCODB_HOST=NOCODB_HOST, NOCODB_API_KEY=NOCODB_API_KEY, SOURCE=SOURCE)
|
@@ -111,7 +110,7 @@ class ProductManager(NocodbClient):
|
|
111
110
|
)
|
112
111
|
logger.info(f"Updated product {product.external_id}")
|
113
112
|
|
114
|
-
async def create_product(self, checked_data: dict, product: ProductModel) -> ProductModel:
|
113
|
+
async def create_product(self, checked_data: dict, product: ProductModel,store_images_at_nocodb: bool=True) -> ProductModel:
|
115
114
|
"""
|
116
115
|
Creates a new product in the table.
|
117
116
|
"""
|
@@ -125,14 +124,15 @@ class ProductManager(NocodbClient):
|
|
125
124
|
|
126
125
|
checked_data[PRODUCT_IMAGES_LOOKUP_FIELD] = [image['title'] for image in checked_data['Images']]
|
127
126
|
|
128
|
-
|
129
|
-
item['
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
127
|
+
if store_images_at_nocodb:
|
128
|
+
for num, item in enumerate(checked_data['Images']):
|
129
|
+
item['url'] = await self.save_image_to_nocodb(
|
130
|
+
source_column_id=self.SOURCE,
|
131
|
+
image_url=item['url'],
|
132
|
+
image_name=item['title'],
|
133
|
+
product_table_name=self.products_table,
|
134
|
+
images_column_id=images_column,
|
135
|
+
)
|
136
136
|
|
137
137
|
record = await self.create_table_record(table_name=self.products_table, record=checked_data)
|
138
138
|
logger.info(f"Created product {external_id}")
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tgshops-integrations
|
3
|
-
Version:
|
3
|
+
Version: 4.0
|
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
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/SOURCES.txt
RENAMED
@@ -14,5 +14,5 @@ tgshops_integrations/nocodb_connector/__init__.py
|
|
14
14
|
tgshops_integrations/nocodb_connector/categories_management.py
|
15
15
|
tgshops_integrations/nocodb_connector/client.py
|
16
16
|
tgshops_integrations/nocodb_connector/model_mapping.py
|
17
|
-
tgshops_integrations/nocodb_connector/products_management.py
|
17
|
+
tgshops_integrations/nocodb_connector/products_management.py.py
|
18
18
|
tgshops_integrations/nocodb_connector/tables.py
|
File without changes
|
File without changes
|
File without changes
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/middlewares/__init__.py
RENAMED
File without changes
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/models/__init__.py
RENAMED
File without changes
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/models/categories.py
RENAMED
File without changes
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations/models/products.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{tgshops_integrations-3.8 → tgshops_integrations-4.0}/tgshops_integrations.egg-info/top_level.txt
RENAMED
File without changes
|