channel-app 0.0.157a9__py3-none-any.whl → 0.0.157a11__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.
- channel_app/alembic.ini +1 -1
- channel_app/app/order/service.py +598 -364
- channel_app/app/product/service.py +392 -238
- channel_app/app/product_image/service.py +214 -134
- channel_app/app/product_price/service.py +390 -240
- channel_app/app/product_stock/service.py +285 -203
- channel_app/app/setup/service.py +133 -79
- channel_app/{alembic → database/migrations}/env.py +2 -3
- channel_app/logs/services.py +1 -1
- channel_app/migrate.py +10 -5
- {channel_app-0.0.157a9.dist-info → channel_app-0.0.157a11.dist-info}/METADATA +1 -1
- {channel_app-0.0.157a9.dist-info → channel_app-0.0.157a11.dist-info}/RECORD +17 -19
- channel_app/alembic/__init__.py +0 -0
- channel_app/alembic/versions/__init__.py +0 -0
- /channel_app/{alembic → database/migrations}/README +0 -0
- /channel_app/{alembic → database/migrations}/script.py.mako +0 -0
- /channel_app/{alembic → database/migrations}/versions/6d5ae5b9c541_create_initial_tables.py +0 -0
- {channel_app-0.0.157a9.dist-info → channel_app-0.0.157a11.dist-info}/WHEEL +0 -0
- {channel_app-0.0.157a9.dist-info → channel_app-0.0.157a11.dist-info}/top_level.txt +0 -0
channel_app/app/setup/service.py
CHANGED
@@ -3,100 +3,154 @@ from typing import List
|
|
3
3
|
from channel_app.core import settings
|
4
4
|
from channel_app.core.data import CategoryTreeDto, ErrorReportDto, AttributeDto
|
5
5
|
from channel_app.core.settings import OmnitronIntegration, ChannelIntegration
|
6
|
+
from channel_app.logs.services import LogService
|
6
7
|
from channel_app.omnitron.constants import ContentType
|
7
8
|
|
8
9
|
|
9
10
|
class SetupService(object):
|
10
11
|
def create_or_update_category_tree_and_nodes(self, is_success_log=False):
|
11
|
-
|
12
|
+
log_service = LogService()
|
13
|
+
log_service.create_flow(name="(Setup) Create or Update Category Tree and Nodes")
|
14
|
+
|
15
|
+
try:
|
16
|
+
with OmnitronIntegration(
|
12
17
|
content_type=ContentType.category_tree.value) as omnitron_integration:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
channel_integration = ChannelIntegration()
|
19
|
+
with log_service.step("get_category_tree_and_nodes"):
|
20
|
+
category_tree, report, _ = channel_integration.do_action(
|
21
|
+
key='get_category_tree_and_nodes',
|
22
|
+
batch_request=omnitron_integration.batch_request)
|
17
23
|
|
18
|
-
|
19
|
-
|
24
|
+
category_tree: CategoryTreeDto
|
25
|
+
report: ErrorReportDto
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
if report and (is_success_log or not report.is_ok):
|
28
|
+
with log_service.step("create_error_report"):
|
29
|
+
omnitron_integration.do_action(
|
30
|
+
key='create_error_report',
|
31
|
+
objects=report)
|
25
32
|
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
with log_service.step("create_or_update_category_tree_and_nodes"):
|
34
|
+
omnitron_integration.do_action(
|
35
|
+
key='create_or_update_category_tree_and_nodes',
|
36
|
+
objects=category_tree)
|
37
|
+
except Exception as fatal:
|
38
|
+
log_service.add_exception(fatal)
|
39
|
+
raise
|
40
|
+
finally:
|
41
|
+
log_service.save()
|
29
42
|
|
30
43
|
def create_or_update_category_attributes(self, is_success_log=False):
|
31
|
-
|
32
|
-
|
33
|
-
channel_integration = ChannelIntegration()
|
34
|
-
category_integration_actions = omnitron_integration.do_action(
|
35
|
-
key='get_category_ids')
|
36
|
-
|
37
|
-
for category_ia in category_integration_actions:
|
38
|
-
if not category_ia.remote_id:
|
39
|
-
continue
|
40
|
-
|
41
|
-
category, report, data = channel_integration.do_action(
|
42
|
-
key='get_category_attributes',
|
43
|
-
objects=category_ia,
|
44
|
-
batch_request=omnitron_integration.batch_request
|
45
|
-
)
|
46
|
-
if report and (is_success_log or not report.is_ok):
|
47
|
-
omnitron_integration.do_action(
|
48
|
-
key='create_error_report',
|
49
|
-
objects=report)
|
44
|
+
log_service = LogService()
|
45
|
+
log_service.create_flow(name="Create or Update Category Attributes")
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
try:
|
48
|
+
with OmnitronIntegration(
|
49
|
+
content_type=ContentType.attribute.value) as omnitron_integration:
|
50
|
+
channel_integration = ChannelIntegration()
|
51
|
+
with log_service.step("get_category_ids"):
|
52
|
+
category_integration_actions = omnitron_integration.do_action(
|
53
|
+
key='get_category_ids')
|
54
|
+
|
55
|
+
for category_ia in category_integration_actions:
|
56
|
+
if not category_ia.remote_id:
|
57
|
+
continue
|
58
|
+
|
59
|
+
with log_service.step("get_category_attributes"):
|
60
|
+
category, report, data = channel_integration.do_action(
|
61
|
+
key='get_category_attributes',
|
62
|
+
objects=category_ia,
|
63
|
+
batch_request=omnitron_integration.batch_request
|
64
|
+
)
|
65
|
+
if report and (is_success_log or not report.is_ok):
|
66
|
+
with log_service.step("create_error_report"):
|
67
|
+
omnitron_integration.do_action(
|
68
|
+
key='create_error_report',
|
69
|
+
objects=report)
|
70
|
+
|
71
|
+
category = category if category.attributes else None
|
72
|
+
with log_service.step("create_or_update_category_attributes"):
|
73
|
+
omnitron_integration.do_action(
|
74
|
+
key='create_or_update_category_attributes',
|
75
|
+
objects=(category_ia, category))
|
76
|
+
except Exception as fatal:
|
77
|
+
log_service.add_exception(fatal)
|
78
|
+
raise
|
79
|
+
finally:
|
80
|
+
log_service.save()
|
55
81
|
|
56
82
|
def create_or_update_attributes(self, is_success_log=False):
|
57
|
-
|
83
|
+
log_service = LogService()
|
84
|
+
log_service.create_flow(name="Create or Update Attributes")
|
85
|
+
|
86
|
+
try:
|
87
|
+
with OmnitronIntegration(
|
58
88
|
content_type=ContentType.attribute.value) as omnitron_integration:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
"
|
91
|
-
"remote_id": attr_value.remote_id
|
89
|
+
channel_integration = ChannelIntegration()
|
90
|
+
with log_service.step("get_attributes"):
|
91
|
+
attributes, report, data = channel_integration.do_action(
|
92
|
+
key='get_attributes',
|
93
|
+
batch_request=omnitron_integration.batch_request
|
94
|
+
)
|
95
|
+
|
96
|
+
attributes: List[AttributeDto]
|
97
|
+
reports: ErrorReportDto
|
98
|
+
|
99
|
+
if report and (is_success_log or not report.is_ok):
|
100
|
+
with log_service.step("create_error_report"):
|
101
|
+
omnitron_integration.do_action(
|
102
|
+
key='create_error_report',
|
103
|
+
objects=report)
|
104
|
+
|
105
|
+
for attribute in attributes:
|
106
|
+
with log_service.step("create_or_update_channel_attribute"):
|
107
|
+
attr = omnitron_integration.do_action(
|
108
|
+
key="create_or_update_channel_attribute",
|
109
|
+
objects={"name": attribute.name,
|
110
|
+
"remote_id": attribute.remote_id},
|
111
|
+
)[0]
|
112
|
+
|
113
|
+
with log_service.step("get_or_create_channel_attribute_schema"):
|
114
|
+
omnitron_integration.do_action(
|
115
|
+
key="get_or_create_channel_attribute_schema",
|
116
|
+
objects={"name": f"{settings.OMNITRON_CHANNEL_ID} {attribute.name} Schema"},
|
117
|
+
)
|
118
|
+
for attr_value in attribute.values:
|
119
|
+
with log_service.step("create_or_update_channel_attribute_value", metadata={
|
120
|
+
"attribute_name": attr_value.name,
|
121
|
+
"remote_id": attr_value.remote_id
|
122
|
+
}):
|
123
|
+
omnitron_integration.do_action(
|
124
|
+
key="create_or_update_channel_attribute_value",
|
125
|
+
objects={
|
126
|
+
"attribute": attr.pk,
|
127
|
+
"label": attr_value.name,
|
128
|
+
"value": attr_value.remote_id,
|
129
|
+
"remote_id": attr_value.remote_id})
|
130
|
+
except Exception as fatal:
|
131
|
+
log_service.add_exception(fatal)
|
132
|
+
raise
|
133
|
+
finally:
|
134
|
+
log_service.save()
|
92
135
|
|
93
136
|
def update_channel_conf_schema(self):
|
94
|
-
|
95
|
-
|
96
|
-
channel_integration = ChannelIntegration()
|
97
|
-
schema, _, _ = channel_integration.do_action(
|
98
|
-
key='get_channel_conf_schema',
|
99
|
-
batch_request=omnitron_integration.batch_request)
|
137
|
+
log_service = LogService()
|
138
|
+
log_service.create_flow(name="Update Channel Conf Schema")
|
100
139
|
|
101
|
-
|
102
|
-
|
140
|
+
try:
|
141
|
+
with OmnitronIntegration(
|
142
|
+
content_type=ContentType.channel.value) as omnitron_integration:
|
143
|
+
channel_integration = ChannelIntegration()
|
144
|
+
with log_service.step("get_channel_conf_schema"):
|
145
|
+
schema, _, _ = channel_integration.do_action(
|
146
|
+
key='get_channel_conf_schema',
|
147
|
+
batch_request=omnitron_integration.batch_request)
|
148
|
+
|
149
|
+
with log_service.step("update_channel_conf_schema"):
|
150
|
+
omnitron_integration.do_action(key="update_channel_conf_schema",
|
151
|
+
objects=schema)
|
152
|
+
except Exception as fatal:
|
153
|
+
log_service.add_exception(fatal)
|
154
|
+
raise
|
155
|
+
finally:
|
156
|
+
log_service.save()
|
@@ -4,8 +4,8 @@ from sqlalchemy import engine_from_config
|
|
4
4
|
from sqlalchemy import pool
|
5
5
|
|
6
6
|
from alembic import context
|
7
|
-
from core import settings
|
8
|
-
from database.models import Base as BaseModel
|
7
|
+
from channel_app.core import settings
|
8
|
+
from channel_app.database.models import Base as BaseModel
|
9
9
|
|
10
10
|
# this is the Alembic Config object, which provides
|
11
11
|
# access to the values within the .ini file in use.
|
@@ -43,7 +43,6 @@ def run_migrations_offline() -> None:
|
|
43
43
|
script output.
|
44
44
|
|
45
45
|
"""
|
46
|
-
DATABASE_URL = f"postgresql+psycopg2://{settings.DB_USER}:{settings.DB_PASSWORD}@{settings.DB_HOST}:{settings.DB_PORT}/{settings.DB_NAME}"
|
47
46
|
url = config.set_main_option("sqlalchemy.url", DATABASE_URL)
|
48
47
|
|
49
48
|
context.configure(
|
channel_app/logs/services.py
CHANGED
@@ -182,7 +182,7 @@ class S3Client:
|
|
182
182
|
"AWS_ACCESS_KEY_ID": os.getenv("AWS_ACCESS_KEY_ID"),
|
183
183
|
"AWS_SECRET_ACCESS_KEY": os.getenv("AWS_SECRET_ACCESS_KEY"),
|
184
184
|
"AWS_REGION": os.getenv("S3_REGION_NAME"),
|
185
|
-
"
|
185
|
+
"S3_BUCKET_NAME": os.getenv("S3_BUCKET_NAME"),
|
186
186
|
}
|
187
187
|
|
188
188
|
missing_vars = [
|
channel_app/migrate.py
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
import os
|
2
|
+
import sys
|
2
3
|
from alembic.config import Config
|
3
4
|
from alembic import command
|
4
5
|
|
5
|
-
def
|
6
|
-
# Bulunduğun dosyadan göreli yol oluştur
|
6
|
+
def migrate():
|
7
7
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
8
8
|
ini_path = os.path.join(base_dir, 'alembic.ini')
|
9
9
|
|
10
|
-
# Alembic yapılandırmasını yükle
|
11
10
|
alembic_cfg = Config(ini_path)
|
11
|
+
alembic_cfg.set_main_option("script_location", os.path.join(base_dir, "database", "migrations"))
|
12
12
|
|
13
|
-
# Migrasyonları uygula (upgrade to head)
|
14
13
|
command.upgrade(alembic_cfg, "head")
|
15
14
|
|
15
|
+
|
16
16
|
if __name__ == "__main__":
|
17
|
-
|
17
|
+
try:
|
18
|
+
migrate()
|
19
|
+
except Exception as e:
|
20
|
+
print(f"Migration failed: {e}")
|
21
|
+
|
22
|
+
sys.exit(1)
|
@@ -1,25 +1,19 @@
|
|
1
1
|
channel_app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
channel_app/alembic.ini,sha256=
|
3
|
-
channel_app/migrate.py,sha256=
|
4
|
-
channel_app/alembic/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
|
5
|
-
channel_app/alembic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
channel_app/alembic/env.py,sha256=09gf5T27hOWppm05teOp9FVyGS99_angdikc91sS35E,2546
|
7
|
-
channel_app/alembic/script.py.mako,sha256=3qBrHBf7F7ChKDUIdiNItiSXrDpgQdM7sR0YKzpaC50,689
|
8
|
-
channel_app/alembic/versions/6d5ae5b9c541_create_initial_tables.py,sha256=EtCzz93LZcBYd7cbIe0w5eYPINduo_Duz4tdetTvTo4,2785
|
9
|
-
channel_app/alembic/versions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
channel_app/alembic.ini,sha256=wUP23krSqffP4Gmo-dXuoceqwi8f7RJaC--7cR-Sfsg,3751
|
3
|
+
channel_app/migrate.py,sha256=jbeWNvgtSbGk9dKXTgM_rGr1NZf3trEfjJvKVhvNmHE,532
|
10
4
|
channel_app/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
5
|
channel_app/app/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
-
channel_app/app/order/service.py,sha256=
|
6
|
+
channel_app/app/order/service.py,sha256=DZyBOkXSF6xTZzzSWFSrKuWK0eAqaMcYp4jbNG_5vWA,31952
|
13
7
|
channel_app/app/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
channel_app/app/product/service.py,sha256=
|
8
|
+
channel_app/app/product/service.py,sha256=i_vw303fxX0zYtNssInct_BRFjpvHIn7YfRMgmh2K5w,18059
|
15
9
|
channel_app/app/product_image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
channel_app/app/product_image/service.py,sha256=
|
10
|
+
channel_app/app/product_image/service.py,sha256=RMc-avIcTT-MlWvtU6Np_Gcq5FDJ3m9hbCclQYEVsiQ,10372
|
17
11
|
channel_app/app/product_price/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
-
channel_app/app/product_price/service.py,sha256=
|
12
|
+
channel_app/app/product_price/service.py,sha256=mF2HCj9vyuAcj524ZcUhLE08wU49-Nl_dWzY7g7sDKI,21300
|
19
13
|
channel_app/app/product_stock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
-
channel_app/app/product_stock/service.py,sha256=
|
14
|
+
channel_app/app/product_stock/service.py,sha256=8wewnWmjNycUEVaPHLLzpX4q_x9uqf2P39JV1Ke-okw,18992
|
21
15
|
channel_app/app/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
-
channel_app/app/setup/service.py,sha256=
|
16
|
+
channel_app/app/setup/service.py,sha256=Pymo7-m6ygcUdJKaDFUHYljTIXqZleeiZ-XAkOWuoxs,7386
|
23
17
|
channel_app/channel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
18
|
channel_app/channel/integration.py,sha256=fDx5nxa6w-4gMucU7xo_OTOkqPHdBUHeDtuzeaDJlXE,3769
|
25
19
|
channel_app/channel/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -43,10 +37,14 @@ channel_app/core/utilities.py,sha256=3iSU4RHFSsdTWBfUYBK23CRGtAIC-nYIBIJLm0Dlx3o
|
|
43
37
|
channel_app/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
38
|
channel_app/database/models.py,sha256=cdjLcfJe-OYZzk1fl3JL6ght8jryRYLwMF2uV3srM-o,2314
|
45
39
|
channel_app/database/services.py,sha256=VkF38jtV_E3Am7459mN5ofvkF1N06gnTWbRdmMzNjYw,354
|
40
|
+
channel_app/database/migrations/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
|
41
|
+
channel_app/database/migrations/env.py,sha256=Adgy3HiFGltE8AidMUwbTS9ff0udW5J8cWuAZ28EDsk,2427
|
42
|
+
channel_app/database/migrations/script.py.mako,sha256=3qBrHBf7F7ChKDUIdiNItiSXrDpgQdM7sR0YKzpaC50,689
|
43
|
+
channel_app/database/migrations/versions/6d5ae5b9c541_create_initial_tables.py,sha256=EtCzz93LZcBYd7cbIe0w5eYPINduo_Duz4tdetTvTo4,2785
|
46
44
|
channel_app/logs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
45
|
channel_app/logs/encoders.py,sha256=6CVgtkV7DrjxGpNXCJgT9bn9B2Ep0lHgtm-0ES7A57I,703
|
48
46
|
channel_app/logs/enums.py,sha256=If6ZjwRTerbJypYI8WjdsleHR7FjlV-TP2nBppFVEc4,214
|
49
|
-
channel_app/logs/services.py,sha256=
|
47
|
+
channel_app/logs/services.py,sha256=ojW6gbYaF2AWt-NgnpEYbFSYUJL6KPZa_lqzQe7WdmI,7168
|
50
48
|
channel_app/omnitron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
49
|
channel_app/omnitron/batch_request.py,sha256=S8IHtbI1RtVLbnOwtfXSmkrREGp8wUYW2E-eu5omwyY,3550
|
52
50
|
channel_app/omnitron/constants.py,sha256=WZR6k_k2zZfN7lfi1ZLv1PphsHIq_LiZgw6Nd6LduvE,2793
|
@@ -73,7 +71,7 @@ channel_app/omnitron/commands/tests/test_product_images.py,sha256=y6tmiJ00kd2GTq
|
|
73
71
|
channel_app/omnitron/commands/tests/test_product_prices.py,sha256=5HPX9PmjGw6gk3oNrwtWLqdrOkfeNx1mYP-pYwOesZU,3496
|
74
72
|
channel_app/omnitron/commands/tests/test_product_stocks.py,sha256=q4RGlrCNUUJyN5CBL1fzrvdd4Q3xt816mbMRQT0XEd0,3496
|
75
73
|
channel_app/omnitron/commands/tests/test_products.py,sha256=uj5KLaubY3XNu0hidOH-u-Djfboe81Hj7-lP--01Le0,103494
|
76
|
-
channel_app-0.0.
|
77
|
-
channel_app-0.0.
|
78
|
-
channel_app-0.0.
|
79
|
-
channel_app-0.0.
|
74
|
+
channel_app-0.0.157a11.dist-info/METADATA,sha256=-OeKhBxlGFeWqTLjnJIzCt1P1IgyK8WnTUvtLhICtec,442
|
75
|
+
channel_app-0.0.157a11.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
76
|
+
channel_app-0.0.157a11.dist-info/top_level.txt,sha256=JT-gM6L5Cwxr1xEoN7NHrREDs-d6iGFGfRnK-NrJ3tU,12
|
77
|
+
channel_app-0.0.157a11.dist-info/RECORD,,
|
channel_app/alembic/__init__.py
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|