tgshops-integrations 4.5__py3-none-any.whl → 4.6__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.
@@ -8,24 +8,22 @@ from tgshops_integrations.nocodb_connector.model_mapping import (
8
8
  dump_product_data,
9
9
  dump_product_data_with_check,
10
10
  get_pagination_info,
11
- parse_product_data,
12
- ID_FIELD,
13
- PRODUCT_CATEGORY_ID_LOOKUP_FIELD,
14
- PRODUCT_NAME_FIELD,
15
- PRODUCT_PRICE_FIELD,
16
- PRODUCT_STOCK_FIELD,
17
- PRODUCT_EXTERNAL_ID,
18
- PRODUCT_IMAGES_LOOKUP_FIELD,
11
+ parse_product_data
19
12
  )
20
13
 
21
14
  class ProductManager(NocodbClient):
22
- def __init__(self, table_id=None, logging=False, NOCODB_HOST=None, NOCODB_API_KEY=None, SOURCE=None):
15
+ def __init__(self, table_id=None, logging=False, NOCODB_HOST=None, NOCODB_API_KEY=None, SOURCE=None, config=None, language="EN"):
16
+
23
17
  super().__init__(NOCODB_HOST=NOCODB_HOST, NOCODB_API_KEY=NOCODB_API_KEY, SOURCE=SOURCE)
24
18
  self.logging = logging
25
- self.required_fields = [PRODUCT_NAME_FIELD, PRODUCT_PRICE_FIELD]
26
19
  self.projection = []
27
20
  self.products_table = table_id
28
21
  self.columns = []
22
+ self.config=config
23
+ self.language=language
24
+
25
+ self.required_fields = [self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_NAME_FIELD'], self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_PRICE_FIELD']]
26
+
29
27
 
30
28
  def hash_product(self, product: ProductModel, special_attributes=False) -> str:
31
29
  """
@@ -68,7 +66,7 @@ class ProductManager(NocodbClient):
68
66
  table_name=self.products_table,
69
67
  required_fields=self.required_fields,
70
68
  projection=self.projection,
71
- extra_where=f"({PRODUCT_NAME_FIELD},like,%{search_string}%)",
69
+ extra_where=f"({self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_NAME_FIELD']},like,%{search_string}%)",
72
70
  limit=limit,
73
71
  )
74
72
  return [parse_product_data(record) for record in records]
@@ -88,7 +86,7 @@ class ProductManager(NocodbClient):
88
86
  """
89
87
  extra_where = None
90
88
  if category_id:
91
- extra_where = f"({PRODUCT_STOCK_FIELD},gt,0)~and({PRODUCT_CATEGORY_ID_LOOKUP_FIELD},eq,{category_id})"
89
+ extra_where = f"({self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_STOCK_FIELD']},gt,0)~and({self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_CATEGORY_ID_LOOKUP_FIELD']},eq,{category_id})"
92
90
 
93
91
  records = await self.get_table_records(
94
92
  table_name=self.products_table,
@@ -119,13 +117,13 @@ class ProductManager(NocodbClient):
119
117
  images_column = next(
120
118
  column["id"]
121
119
  for column in metadata["columns"]
122
- if column["column_name"] == "Images"
120
+ if column["title"] == self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_IMAGE_FIELD']
123
121
  )
124
122
 
125
- checked_data[PRODUCT_IMAGES_LOOKUP_FIELD] = [image['title'] for image in checked_data['Images']]
123
+ checked_data[self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_IMAGES_LOOKUP_FIELD']] = [image['title'] for image in checked_data[self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_IMAGE_FIELD']]]
126
124
 
127
125
  if store_images_at_nocodb:
128
- for num, item in enumerate(checked_data['Images']):
126
+ for num, item in enumerate(checked_data[self.config.NOCODB_PRODUCTS[self.language]['PRODUCT_IMAGE_FIELD']]):
129
127
  item['url'] = await self.save_image_to_nocodb(
130
128
  source_column_id=self.SOURCE,
131
129
  image_url=item['url'],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tgshops-integrations
3
- Version: 4.5
3
+ Version: 4.6
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_management.py,sha256=jVbgkKmCDUuGj1zZyIO041m0pvQRnV0pyEZGnwDa2U4,7921
9
9
  tgshops_integrations/nocodb_connector/client.py,sha256=3MLTOLInxhsr4H0nt71k09ozgUyRzGV2onYZuFWQJzI,12487
10
10
  tgshops_integrations/nocodb_connector/model_mapping.py,sha256=rTzBH6lKbxcLTvlOSVkIriSOYjnwhqIHx0wiXPTxHwo,9540
11
- tgshops_integrations/nocodb_connector/products_management.py,sha256=q0zrlybfnnXeAiqDpchV_zq4BoMJUS6q2zid1eshSM0,6179
11
+ tgshops_integrations/nocodb_connector/products_management.py,sha256=ChwF6r2llfCtZU83fijLPgcO0SUGUMTQYCLIoKEQIVs,6532
12
12
  tgshops_integrations/nocodb_connector/tables.py,sha256=ha_QXZXd93mht0fR5E1nM0wUpz1ePon-pIdO2HI67l8,356
13
- tgshops_integrations-4.5.dist-info/METADATA,sha256=6ZcGuG7uliCX-UbfUGrPnANkXMVb-7l9EPCIFHcoSk8,2844
14
- tgshops_integrations-4.5.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
15
- tgshops_integrations-4.5.dist-info/top_level.txt,sha256=HFNtxqDpzmlF4ZLnMiwhbU7pOa_YozxU2zBl0bnUmcY,21
16
- tgshops_integrations-4.5.dist-info/RECORD,,
13
+ tgshops_integrations-4.6.dist-info/METADATA,sha256=nHc68LVFHrueH8i39-msz5RgrUqLRYlNTlECQV0iFtg,2844
14
+ tgshops_integrations-4.6.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
15
+ tgshops_integrations-4.6.dist-info/top_level.txt,sha256=HFNtxqDpzmlF4ZLnMiwhbU7pOa_YozxU2zBl0bnUmcY,21
16
+ tgshops_integrations-4.6.dist-info/RECORD,,