viur-shop 0.1.0.dev2__tar.gz
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.
- viur-shop-0.1.0.dev2/LICENSE +21 -0
- viur-shop-0.1.0.dev2/PKG-INFO +21 -0
- viur-shop-0.1.0.dev2/README.md +1 -0
- viur-shop-0.1.0.dev2/pyproject.toml +6 -0
- viur-shop-0.1.0.dev2/setup.cfg +29 -0
- viur-shop-0.1.0.dev2/setup.py +3 -0
- viur-shop-0.1.0.dev2/src/viur/shop/__init__.py +9 -0
- viur-shop-0.1.0.dev2/src/viur/shop/constants.py +87 -0
- viur-shop-0.1.0.dev2/src/viur/shop/modules/__init__.py +1 -0
- viur-shop-0.1.0.dev2/src/viur/shop/modules/abstract.py +29 -0
- viur-shop-0.1.0.dev2/src/viur/shop/modules/api.py +204 -0
- viur-shop-0.1.0.dev2/src/viur/shop/modules/cart.py +12 -0
- viur-shop-0.1.0.dev2/src/viur/shop/payment_providers/__init__.py +1 -0
- viur-shop-0.1.0.dev2/src/viur/shop/payment_providers/abstract.py +39 -0
- viur-shop-0.1.0.dev2/src/viur/shop/shop.py +64 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/__init__.py +19 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/address.py +73 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/article.py +72 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/cart.py +122 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/discount.py +50 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/discount_condition.py +119 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/order.py +79 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/shipping.py +55 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/shipping_config.py +19 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/shipping_precondition.py +22 -0
- viur-shop-0.1.0.dev2/src/viur/shop/skeletons/vat.py +16 -0
- viur-shop-0.1.0.dev2/src/viur/shop/version.py +9 -0
- viur-shop-0.1.0.dev2/src/viur_shop.egg-info/PKG-INFO +21 -0
- viur-shop-0.1.0.dev2/src/viur_shop.egg-info/SOURCES.txt +30 -0
- viur-shop-0.1.0.dev2/src/viur_shop.egg-info/dependency_links.txt +1 -0
- viur-shop-0.1.0.dev2/src/viur_shop.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 ViUR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: viur-shop
|
|
3
|
+
Version: 0.1.0.dev2
|
|
4
|
+
Summary: A ViUR-shop
|
|
5
|
+
Home-page: https://github.com/viur-framework/viur-shop
|
|
6
|
+
Author: Sven Eberth
|
|
7
|
+
Author-email: se@mausbrand.de
|
|
8
|
+
Maintainer: Sven Eberth
|
|
9
|
+
Maintainer-email: se@mausbrand.de
|
|
10
|
+
Classifier: Development Status :: 1 - Planning
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
|
|
21
|
+
# viur-shop (WIP)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# viur-shop (WIP)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = viur-shop
|
|
3
|
+
version = attr: viur.shop.version.__version__
|
|
4
|
+
author = Sven Eberth
|
|
5
|
+
author_email = se@mausbrand.de
|
|
6
|
+
maintainer = Sven Eberth
|
|
7
|
+
maintainer_email = se@mausbrand.de
|
|
8
|
+
description = A ViUR-shop
|
|
9
|
+
long_description = file: README.md
|
|
10
|
+
long_description_content_type = text/markdown
|
|
11
|
+
url = https://github.com/viur-framework/viur-shop
|
|
12
|
+
classifiers =
|
|
13
|
+
Development Status :: 1 - Planning
|
|
14
|
+
Intended Audience :: Developers
|
|
15
|
+
License :: OSI Approved :: MIT License
|
|
16
|
+
Operating System :: OS Independent
|
|
17
|
+
Programming Language :: Python :: 3.10
|
|
18
|
+
Programming Language :: Python :: 3.11
|
|
19
|
+
Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
|
|
21
|
+
[options]
|
|
22
|
+
python_requires = >=3.10
|
|
23
|
+
package_dir =
|
|
24
|
+
= src
|
|
25
|
+
|
|
26
|
+
[egg_info]
|
|
27
|
+
tag_build =
|
|
28
|
+
tag_date = 0
|
|
29
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ArticleAvailability(enum.Enum):
|
|
5
|
+
IN_STOCK = "instock"
|
|
6
|
+
OUT_OF_STOCK = "outofstock"
|
|
7
|
+
LIMITED = "limited"
|
|
8
|
+
DISCONTINUED = "discontinued"
|
|
9
|
+
PREORDER = "preorder"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CartType(enum.Enum):
|
|
13
|
+
WISHLIST = "wishlist"
|
|
14
|
+
BASKET = "basket"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CustomerType(enum.Enum):
|
|
18
|
+
PRIVATE = "private"
|
|
19
|
+
BUSINESS = "business"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Salutation(enum.Enum):
|
|
23
|
+
FEMALE = "female"
|
|
24
|
+
MALE = "male"
|
|
25
|
+
OTHER = "other"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AddressType(enum.Enum):
|
|
29
|
+
BILLING = "billing"
|
|
30
|
+
SHIPPING = "shipping"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CodeType(enum.Enum):
|
|
34
|
+
NONE = None # TODO: is this working?
|
|
35
|
+
INDIVIDUAL = "individual"
|
|
36
|
+
UNIVERSAL = "universal"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ApplicationDomain(enum.Enum):
|
|
40
|
+
BASKET = "basket"
|
|
41
|
+
ARTICLE = "article"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class CustomerGroup(enum.Enum):
|
|
45
|
+
NONE = None # TODO: is this working?
|
|
46
|
+
"""none (alle Kunden)"""
|
|
47
|
+
|
|
48
|
+
FIRST_ORDER = "first_order"
|
|
49
|
+
"""Erstbestellung"""
|
|
50
|
+
|
|
51
|
+
FOLLOW_UP_ORDER = "follow_up_order"
|
|
52
|
+
"""Folgebestellung "Stammkunden" (mind. eine Bestellung)"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class DiscountType(enum.Enum):
|
|
56
|
+
PERCENTAGE = "percentage"
|
|
57
|
+
"""percentage"""
|
|
58
|
+
|
|
59
|
+
ABSOLUTE = "absolute"
|
|
60
|
+
"""absolute"""
|
|
61
|
+
|
|
62
|
+
FREE_ARTICLE = "free_article"
|
|
63
|
+
"""free-article (and cart easter egg)"""
|
|
64
|
+
|
|
65
|
+
FREE_SHIPPING = "free_shipping"
|
|
66
|
+
"""free-shipping"""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ConditionOperator(enum.Enum):
|
|
70
|
+
# TODO: Shall we name them "one" and "all" instead of "or" and "AND"?
|
|
71
|
+
|
|
72
|
+
OR = "or"
|
|
73
|
+
"""One condition must be satisfied"""
|
|
74
|
+
|
|
75
|
+
AND = "and"
|
|
76
|
+
"""All conditions must be satisfied"""
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class OrderState(enum.Enum):
|
|
80
|
+
ORDERED = "ordered"
|
|
81
|
+
"""Customer completed this order and clicked on buy"""
|
|
82
|
+
|
|
83
|
+
PAID = "paid"
|
|
84
|
+
"""Payment completed"""
|
|
85
|
+
|
|
86
|
+
RTS = "rts"
|
|
87
|
+
"""Ready To Send (but must not be paid)"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .cart import *
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from viur.core import Module
|
|
4
|
+
|
|
5
|
+
if t.TYPE_CHECKING:
|
|
6
|
+
from viur.shop import Shop
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ShopModuleAbstract(Module):
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
moduleName: str = None,
|
|
18
|
+
modulePath: str = None,
|
|
19
|
+
shop: "Shop" = None,
|
|
20
|
+
*args, **kwargs
|
|
21
|
+
):
|
|
22
|
+
if shop is None:
|
|
23
|
+
raise ValueError("Missing shop argument!")
|
|
24
|
+
if moduleName is None:
|
|
25
|
+
moduleName = self.__class__.__name__
|
|
26
|
+
if modulePath is None:
|
|
27
|
+
modulePath = f"{shop.modulePath}/{moduleName.lower()}"
|
|
28
|
+
super().__init__(moduleName, modulePath, *args, **kwargs)
|
|
29
|
+
self.shop: "Shop" = shop
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core import db, exposed
|
|
4
|
+
from viur.shop.constants import CartType
|
|
5
|
+
from viur.shop.modules.abstract import ShopModuleAbstract
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# TODO: add methods
|
|
11
|
+
# TODO: add permission concept
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Api(ShopModuleAbstract):
|
|
15
|
+
|
|
16
|
+
@exposed
|
|
17
|
+
def article_view(
|
|
18
|
+
self,
|
|
19
|
+
article_key: str | db.Key,
|
|
20
|
+
parent_cart_key: str | db.Key,
|
|
21
|
+
):
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
@exposed
|
|
25
|
+
def article_add(
|
|
26
|
+
self,
|
|
27
|
+
article_key: str | db.Key,
|
|
28
|
+
quantity: int,
|
|
29
|
+
parent_cart_key: str | db.Key,
|
|
30
|
+
):
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
@exposed
|
|
34
|
+
def article_update(
|
|
35
|
+
self,
|
|
36
|
+
article_key: str | db.Key,
|
|
37
|
+
quantity: int,
|
|
38
|
+
parent_cart_key: str | db.Key,
|
|
39
|
+
):
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
@exposed
|
|
43
|
+
def article_remove(
|
|
44
|
+
self,
|
|
45
|
+
article_key: str | db.Key,
|
|
46
|
+
parent_cart_key: str | db.Key,
|
|
47
|
+
):
|
|
48
|
+
return self.article_update(article_key, 0, parent_cart_key)
|
|
49
|
+
|
|
50
|
+
@exposed
|
|
51
|
+
def article_move(
|
|
52
|
+
self,
|
|
53
|
+
article_key: str | db.Key,
|
|
54
|
+
parent_cart_key: str | db.Key,
|
|
55
|
+
new_parent_cart_key: str | db.Key,
|
|
56
|
+
):
|
|
57
|
+
...
|
|
58
|
+
|
|
59
|
+
@exposed
|
|
60
|
+
def cart_add(
|
|
61
|
+
self,
|
|
62
|
+
parent_cart_key: str | db.Key,
|
|
63
|
+
cart_type: CartType,
|
|
64
|
+
name: str = None,
|
|
65
|
+
customer_comment: str = None,
|
|
66
|
+
shipping_address_key: str | db.Key = None,
|
|
67
|
+
shipping_key: str | db.Key = None,
|
|
68
|
+
):
|
|
69
|
+
...
|
|
70
|
+
|
|
71
|
+
@exposed
|
|
72
|
+
def cart_update(
|
|
73
|
+
self,
|
|
74
|
+
cart_key: str | db.Key,
|
|
75
|
+
name: str = None,
|
|
76
|
+
customer_comment: str = None,
|
|
77
|
+
shipping_address_key: str | db.Key = None,
|
|
78
|
+
shipping_key: str | db.Key = None,
|
|
79
|
+
):
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
@exposed
|
|
83
|
+
def cart_remove(
|
|
84
|
+
self,
|
|
85
|
+
cart_key: str | db.Key,
|
|
86
|
+
):
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
@exposed
|
|
90
|
+
def cart_clear(
|
|
91
|
+
self,
|
|
92
|
+
cart_key: str | db.Key,
|
|
93
|
+
remove_sub_carts: bool = False,
|
|
94
|
+
):
|
|
95
|
+
...
|
|
96
|
+
|
|
97
|
+
@exposed
|
|
98
|
+
def cart_list(
|
|
99
|
+
self,
|
|
100
|
+
cart_key: str | db.Key,
|
|
101
|
+
):
|
|
102
|
+
"""
|
|
103
|
+
kein node_key: Listet root-nodes auf
|
|
104
|
+
|
|
105
|
+
node_key: listet direkte Kinder (leafs und nodes) auf
|
|
106
|
+
"""
|
|
107
|
+
...
|
|
108
|
+
|
|
109
|
+
@exposed
|
|
110
|
+
def order_add(
|
|
111
|
+
self,
|
|
112
|
+
order_key: str | db.Key,
|
|
113
|
+
payment_provider: str = None,
|
|
114
|
+
billing_address_key: str | db.Key = None,
|
|
115
|
+
email: str = None,
|
|
116
|
+
customer_key: str | db.Key = None,
|
|
117
|
+
state_ordered: bool = None,
|
|
118
|
+
state_paid: bool = None,
|
|
119
|
+
state_rts: bool = None,
|
|
120
|
+
):
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
@exposed
|
|
124
|
+
def order_update(
|
|
125
|
+
self,
|
|
126
|
+
order_key: str | db.Key,
|
|
127
|
+
payment_provider: str = None,
|
|
128
|
+
billing_address_key: str | db.Key = None,
|
|
129
|
+
email: str = None,
|
|
130
|
+
customer_key: str | db.Key = None,
|
|
131
|
+
state_ordered: bool = None,
|
|
132
|
+
state_paid: bool = None,
|
|
133
|
+
state_rts: bool = None,
|
|
134
|
+
):
|
|
135
|
+
...
|
|
136
|
+
|
|
137
|
+
@exposed
|
|
138
|
+
def order_remove(
|
|
139
|
+
self,
|
|
140
|
+
order_key: str | db.Key,
|
|
141
|
+
):
|
|
142
|
+
...
|
|
143
|
+
|
|
144
|
+
@exposed
|
|
145
|
+
def order_view(
|
|
146
|
+
self,
|
|
147
|
+
order_key: str | db.Key,
|
|
148
|
+
):
|
|
149
|
+
"""
|
|
150
|
+
Gibt gesetzte Werte (BillAddress) aus und gibt computed Wert "is_orderable" aus,
|
|
151
|
+
ob alle Vorbedingungen für Bestellabschluss erfüllt sind.
|
|
152
|
+
"""
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
@exposed
|
|
156
|
+
def discount_add(
|
|
157
|
+
self,
|
|
158
|
+
code: str,
|
|
159
|
+
discount_key: str | db.Key,
|
|
160
|
+
):
|
|
161
|
+
"""
|
|
162
|
+
parameter code xor discount_key: str | db.Key
|
|
163
|
+
|
|
164
|
+
Sucht nach Rabatt mit dem code xor key, je nach Typ (Artikel/Warenkorb) suche ...ende parent_node oder erzeuge eine und setze dort die discount Relation.
|
|
165
|
+
"""
|
|
166
|
+
...
|
|
167
|
+
|
|
168
|
+
@exposed
|
|
169
|
+
def discount_remove(
|
|
170
|
+
self,
|
|
171
|
+
discount_key: str | db.Key,
|
|
172
|
+
):
|
|
173
|
+
...
|
|
174
|
+
|
|
175
|
+
@exposed
|
|
176
|
+
def shipping_list(
|
|
177
|
+
self,
|
|
178
|
+
cart_key: str | db.Key,
|
|
179
|
+
):
|
|
180
|
+
"""
|
|
181
|
+
Listet verfügbar Versandoptionen für einen (Unter)Warenkorb auf
|
|
182
|
+
"""
|
|
183
|
+
...
|
|
184
|
+
|
|
185
|
+
# --- Testing only --------------------------------------------------------
|
|
186
|
+
|
|
187
|
+
@exposed
|
|
188
|
+
def tmp_article_list(self): # TODO testing only
|
|
189
|
+
return [
|
|
190
|
+
skel["shop_name"]
|
|
191
|
+
for skel in self.shop.article_skel().all().fetch()
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
@exposed
|
|
195
|
+
def tmp_article_gen(self): # TODO testing only
|
|
196
|
+
for i in range(10):
|
|
197
|
+
skel = self.shop.article_skel()
|
|
198
|
+
skel["shop_name"] = f"Article #{str(i).zfill(5)}"
|
|
199
|
+
skel.toDB()
|
|
200
|
+
logger.info(f"Added article skel {skel}")
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
Api.html = True
|
|
204
|
+
Api.vi = True
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core import exposed
|
|
4
|
+
from viur.shop.modules.abstract import ShopModuleAbstract
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Cart(ShopModuleAbstract):
|
|
10
|
+
@exposed
|
|
11
|
+
def index(self):
|
|
12
|
+
return "your cart is empty -.-"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .abstract import PaymentProviderAbstract
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PaymentProviderAbstract(abc.ABC):
|
|
9
|
+
@property
|
|
10
|
+
@abc.abstractmethod
|
|
11
|
+
def name(self) -> str:
|
|
12
|
+
...
|
|
13
|
+
|
|
14
|
+
@abc.abstractmethod
|
|
15
|
+
def checkout(self):
|
|
16
|
+
...
|
|
17
|
+
|
|
18
|
+
@abc.abstractmethod
|
|
19
|
+
def charge(self):
|
|
20
|
+
...
|
|
21
|
+
|
|
22
|
+
@abc.abstractmethod
|
|
23
|
+
def check_payment_state(self):
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
@abc.abstractmethod
|
|
27
|
+
# @exposed
|
|
28
|
+
def return_hook(self):
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
@abc.abstractmethod
|
|
32
|
+
# @exposed
|
|
33
|
+
def webhook(self):
|
|
34
|
+
...
|
|
35
|
+
|
|
36
|
+
@abc.abstractmethod
|
|
37
|
+
# @exposed
|
|
38
|
+
def get_debug_information(self):
|
|
39
|
+
...
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import typing as t
|
|
3
|
+
|
|
4
|
+
from viur.core.decorators import exposed
|
|
5
|
+
from viur.core.module import Module
|
|
6
|
+
from viur.core.prototypes.instanced_module import InstancedModule
|
|
7
|
+
from viur.core.skeleton import Skeleton
|
|
8
|
+
from .modules import Cart
|
|
9
|
+
from .modules.api import Api
|
|
10
|
+
from .payment_providers import PaymentProviderAbstract
|
|
11
|
+
from .skeletons.discount_condition import DiscountConditionSkel
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Shop(InstancedModule, Module):
|
|
17
|
+
@exposed
|
|
18
|
+
def hello(self):
|
|
19
|
+
return f"Welcome to the {self.name} Shop!"
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
name: str,
|
|
24
|
+
article_skel: t.Type[Skeleton],
|
|
25
|
+
payment_providers: list[PaymentProviderAbstract],
|
|
26
|
+
*args, **kwargs,
|
|
27
|
+
):
|
|
28
|
+
logger.debug(f"Shop.__init__()")
|
|
29
|
+
super().__init__()
|
|
30
|
+
|
|
31
|
+
# Store arguments
|
|
32
|
+
self.name: str = name
|
|
33
|
+
self.article_skel: t.Type[Skeleton] = article_skel
|
|
34
|
+
self.payment_providers: list[PaymentProviderAbstract] = payment_providers
|
|
35
|
+
self.additional_settings: dict[str, t.Any] = dict(kwargs)
|
|
36
|
+
|
|
37
|
+
self._set_kind_names()
|
|
38
|
+
|
|
39
|
+
# Debug only
|
|
40
|
+
logger.debug(f"{vars(self) = }")
|
|
41
|
+
|
|
42
|
+
def __call__(self, *args, **kwargs):
|
|
43
|
+
logger.debug(f"Shop.__call__({args=}, {kwargs=})")
|
|
44
|
+
self: Shop = super().__call__(*args, **kwargs) # noqa
|
|
45
|
+
# Add sub modules
|
|
46
|
+
self.api = Api("api", f"{self.modulePath}/cart", shop=self)
|
|
47
|
+
self.cart = Cart("cart", f"{self.modulePath}/cart", shop=self)
|
|
48
|
+
self._update_methods()
|
|
49
|
+
return self
|
|
50
|
+
|
|
51
|
+
def _set_kind_names(self):
|
|
52
|
+
"""Set kindname of bones where the kind name can be dynamically
|
|
53
|
+
|
|
54
|
+
At this point we are and must be before setSystemInitialized.
|
|
55
|
+
"""
|
|
56
|
+
from viur.shop import CartItemSkel
|
|
57
|
+
CartItemSkel.article.kind = self.article_skel.kindName
|
|
58
|
+
DiscountConditionSkel.scope_article.kind = self.article_skel.kindName
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Shop.html = True
|
|
64
|
+
Shop.vi = True
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from viur.core import conf
|
|
4
|
+
|
|
5
|
+
# Before we can import any skeleton we must allow this dir in the viur-core
|
|
6
|
+
_dir = str(Path(__file__).parent)
|
|
7
|
+
if _dir not in conf.skeleton_search_path:
|
|
8
|
+
conf.skeleton_search_path.append(_dir)
|
|
9
|
+
|
|
10
|
+
from .address import AddressSkel
|
|
11
|
+
from .article import ArticleAbstractSkel
|
|
12
|
+
from .cart import CartNodeSkel, CartItemSkel
|
|
13
|
+
from .discount import DiscountSkel
|
|
14
|
+
from .discount_condition import DiscountConditionSkel
|
|
15
|
+
from .order import OrderSkel
|
|
16
|
+
from .shipping import ShippingSkel
|
|
17
|
+
from .shipping_config import ShippingConfigSkel
|
|
18
|
+
from .shipping_precondition import ShippingPreconditionRelSkel
|
|
19
|
+
from .vat import VatSkel
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import Skeleton
|
|
5
|
+
from viur.shop.constants import *
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# TODO: should these bones required or will this be handled in a editSkel?
|
|
11
|
+
|
|
12
|
+
class AddressSkel(Skeleton): # STATE: Complete (as in model)
|
|
13
|
+
kindName = "shop_address"
|
|
14
|
+
|
|
15
|
+
customer_type = SelectBone(
|
|
16
|
+
descr="customer_type",
|
|
17
|
+
values=CustomerType,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
salutation = SelectBone(
|
|
21
|
+
descr="salutation",
|
|
22
|
+
values=Salutation,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
company_name = StringBone(
|
|
26
|
+
descr="company_name",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
firstname = StringBone(
|
|
30
|
+
descr="firstname",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
lastname = StringBone(
|
|
34
|
+
descr="lastname",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
street_name = StringBone(
|
|
38
|
+
descr="street_name",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
street_number = StringBone(
|
|
42
|
+
descr="street_number",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
address_addition = StringBone(
|
|
46
|
+
descr="address_addition",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
zip_code = StringBone(
|
|
50
|
+
descr="zip_code",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
city = StringBone(
|
|
54
|
+
descr="city",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
country = SelectCountryBone(
|
|
58
|
+
descr="country",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
customer = RelationalBone(
|
|
62
|
+
descr="customer",
|
|
63
|
+
kind="user",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
is_default = BooleanBone(
|
|
67
|
+
descr="is_default",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
address_type = SelectBone(
|
|
71
|
+
descr="address_type",
|
|
72
|
+
values=AddressType,
|
|
73
|
+
)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# FIXME: TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
|
|
9
|
+
class ArticleAbstractSkel: # FIXME: (abc.ABC):
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
@abc.abstractmethod
|
|
13
|
+
def shop_name(self):
|
|
14
|
+
"""Name of the article in the shop"""
|
|
15
|
+
...
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
@abc.abstractmethod
|
|
19
|
+
def shop_description(self):
|
|
20
|
+
...
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
@abc.abstractmethod
|
|
24
|
+
def shop_price_retail(self):
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
@abc.abstractmethod
|
|
29
|
+
def shop_price_recommended(self):
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
@abc.abstractmethod
|
|
34
|
+
def shop_availability(self):
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
@abc.abstractmethod
|
|
39
|
+
def shop_listed(self) -> bool:
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
@abc.abstractmethod
|
|
44
|
+
def shop_image(self):
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
@abc.abstractmethod
|
|
49
|
+
def shop_art_no_or_gtin(self):
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
@abc.abstractmethod
|
|
54
|
+
def shop_vat(self):
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
@abc.abstractmethod
|
|
59
|
+
def shop_shipping(self):
|
|
60
|
+
...
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
@abc.abstractmethod
|
|
64
|
+
def shop_is_weee(self) -> bool:
|
|
65
|
+
"""Waste Electrical and Electronic Equipment Directive (WEEE Directive)"""
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
@abc.abstractmethod
|
|
70
|
+
def shop_is_low_price(self) -> bool:
|
|
71
|
+
"""shop_price_retail != shop_price_recommended"""
|
|
72
|
+
...
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.prototypes.tree import TreeSkel
|
|
5
|
+
from viur.shop.constants import *
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CartNodeSkel(TreeSkel): # STATE: Complete (as in model)
|
|
11
|
+
kindName = "shop_cart_node"
|
|
12
|
+
|
|
13
|
+
total = NumericBone(
|
|
14
|
+
descr="Total",
|
|
15
|
+
precision=2,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
vat_total = NumericBone(
|
|
19
|
+
descr="Total",
|
|
20
|
+
precision=2,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
vat_rate = RelationalBone(
|
|
24
|
+
descr="Vat Rate",
|
|
25
|
+
kind="shop_vat",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
shipping_address = RelationalBone(
|
|
29
|
+
descr="shipping_address",
|
|
30
|
+
kind="shop_address",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
customer_comment = TextBone(
|
|
34
|
+
descr="customer_comment",
|
|
35
|
+
validHtml=None,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
name = StringBone(
|
|
39
|
+
descr="name",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
cart_type = SelectBone(
|
|
43
|
+
descr="cart_type",
|
|
44
|
+
values=CartType,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
shipping = RelationalBone(
|
|
48
|
+
descr="shipping",
|
|
49
|
+
kind="shop_shipping",
|
|
50
|
+
)
|
|
51
|
+
"""Versand bei Warenkorb der einer Bestellung zugehört"""
|
|
52
|
+
|
|
53
|
+
discount = RelationalBone(
|
|
54
|
+
descr="discount",
|
|
55
|
+
kind="shop_discount",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class CartItemSkel(TreeSkel): # STATE: Complete (as in model)
|
|
60
|
+
kindName = "shop_cart_leaf"
|
|
61
|
+
|
|
62
|
+
article = RelationalBone(
|
|
63
|
+
descr="article",
|
|
64
|
+
kind="...", # will be set in Shop._set_kind_names()
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
project_data = JsonBone(
|
|
68
|
+
descr="Custom project data",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# --- Bones to store a frozen copy of the article values: -----------------
|
|
72
|
+
|
|
73
|
+
shop_name = StringBone(
|
|
74
|
+
descr="shop_name",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
shop_description = TextBone(
|
|
78
|
+
descr="shop_description",
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
shop_price_retail = NumericBone(
|
|
82
|
+
descr="Verkaufspreis",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
shop_price_recommended = NumericBone(
|
|
86
|
+
descr="UVP",
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
shop_availability = SelectBone(
|
|
90
|
+
descr="shop_availability",
|
|
91
|
+
values=ArticleAvailability,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
shop_listed = BooleanBone(
|
|
95
|
+
descr="shop_listed",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
shop_image = FileBone(
|
|
99
|
+
descr="Produktbild",
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
shop_art_no_or_gtin = StringBone(
|
|
103
|
+
descr="Artikelnummer",
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
shop_vat = RelationalBone(
|
|
107
|
+
descr="Steuersatz",
|
|
108
|
+
kind="shop_vat",
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
shop_shipping = RelationalBone(
|
|
112
|
+
descr="Versandkosten",
|
|
113
|
+
kind="shop_shipping",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
shop_is_weee = BooleanBone(
|
|
117
|
+
descr="Elektro",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
shop_is_low_price = BooleanBone(
|
|
121
|
+
descr="shop_is_low_price",
|
|
122
|
+
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import Skeleton
|
|
5
|
+
from viur.shop.constants import *
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DiscountSkel(Skeleton): # STATE: Complete (as in model)
|
|
11
|
+
kindName = "shop_discount"
|
|
12
|
+
|
|
13
|
+
name = StringBone(
|
|
14
|
+
descr="name",
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
description = TextBone(
|
|
18
|
+
descr="description",
|
|
19
|
+
validHtml=None,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
discount_type = SelectBone(
|
|
23
|
+
descr="discount_type",
|
|
24
|
+
values=DiscountType,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
absolute = NumericBone(
|
|
28
|
+
descr="absolute",
|
|
29
|
+
precision=2,
|
|
30
|
+
min=0,
|
|
31
|
+
# TODO: UnitBone / CurrencyBone
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
percentage = NumericBone(
|
|
35
|
+
descr="percentage",
|
|
36
|
+
precision=2,
|
|
37
|
+
min=0,
|
|
38
|
+
max=100,
|
|
39
|
+
# TODO: UnitBone / PercentageBone
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
condition = RelationalBone(
|
|
43
|
+
descr="condition",
|
|
44
|
+
kind="shop_discount_condition",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
condition_operator = SelectBone(
|
|
48
|
+
descr="condition_operator",
|
|
49
|
+
values=ConditionOperator,
|
|
50
|
+
)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core import conf
|
|
4
|
+
from viur.core.bones import *
|
|
5
|
+
from viur.core.skeleton import Skeleton
|
|
6
|
+
from viur.shop.constants import *
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DiscountConditionSkel(Skeleton): # STATE: Complete (as in model)
|
|
12
|
+
kindName = "shop_discount_condition"
|
|
13
|
+
|
|
14
|
+
code_type = SelectBone(
|
|
15
|
+
descr="code_type",
|
|
16
|
+
values=CodeType,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
application_domain = SelectBone(
|
|
20
|
+
descr="application_domain",
|
|
21
|
+
values=ApplicationDomain,
|
|
22
|
+
)
|
|
23
|
+
"""Anwendungsbereich"""
|
|
24
|
+
|
|
25
|
+
quantity_volume = NumericBone(
|
|
26
|
+
descr="quantity_volume",
|
|
27
|
+
defaultValue=-1, # Unlimited
|
|
28
|
+
min=-1,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
quantity_used = NumericBone(
|
|
32
|
+
descr="quantity_used",
|
|
33
|
+
defaultValue=0,
|
|
34
|
+
min=0,
|
|
35
|
+
)
|
|
36
|
+
"""Wie oft wurde der code Bereits verwendet?"""
|
|
37
|
+
|
|
38
|
+
individual_codes_amount = NumericBone(
|
|
39
|
+
descr="individual_codes_amount",
|
|
40
|
+
min=1,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
scope_code = StringBone(
|
|
44
|
+
descr="code",
|
|
45
|
+
# TODO: limit charset
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
individual_codes_prefix = StringBone(
|
|
49
|
+
descr="individual_codes_prefix",
|
|
50
|
+
# TODO: limit charset
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
scope_minimum_order_value = NumericBone(
|
|
54
|
+
descr="scope_minimum_order_value",
|
|
55
|
+
min=0,
|
|
56
|
+
# TODO: UnitBone / CurrencyBone
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
scope_date_start = DateBone(
|
|
60
|
+
descr="scope_date_start",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
scope_date_end = DateBone(
|
|
64
|
+
descr="scope_date_end",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
scope_language = SelectBone(
|
|
68
|
+
descr="scope_language",
|
|
69
|
+
values=conf.i18n.available_languages,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
scope_country = SelectCountryBone(
|
|
73
|
+
descr="scope_country",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
scope_minimum_quantity = NumericBone(
|
|
77
|
+
descr="scope_minimum_quantity",
|
|
78
|
+
min=0,
|
|
79
|
+
)
|
|
80
|
+
"""Minimale Anzahl
|
|
81
|
+
|
|
82
|
+
für Staffelrabatte (in Kombination mit application_domain) für Artikel oder kompletten Warenkorb"""
|
|
83
|
+
|
|
84
|
+
scope_customer_group = SelectBone(
|
|
85
|
+
descr="scope_customer_group",
|
|
86
|
+
values=CustomerGroup,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
scope_combinable_other_discount = BooleanBone(
|
|
90
|
+
descr="scope_combinable_other_discount",
|
|
91
|
+
)
|
|
92
|
+
"""Kombinierbar mit anderen Rabatten"""
|
|
93
|
+
|
|
94
|
+
scope_combinable_low_price = BooleanBone(
|
|
95
|
+
descr="scope_combinable_low_price",
|
|
96
|
+
)
|
|
97
|
+
"""Kombinierbar
|
|
98
|
+
|
|
99
|
+
prüfen mit shop_is_low_price"""
|
|
100
|
+
|
|
101
|
+
scope_article = RelationalBone(
|
|
102
|
+
descr="scope_article",
|
|
103
|
+
kind="...", # will be set in Shop._set_kind_names()
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
is_subcode = BooleanBone(
|
|
107
|
+
descr="is_subcode",
|
|
108
|
+
compute=Compute(
|
|
109
|
+
fn=lambda skel: skel["parent_code"] is not None,
|
|
110
|
+
interval=ComputeInterval(
|
|
111
|
+
method=ComputeMethod.OnWrite,
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
parent_code = RelationalBone(
|
|
117
|
+
descr="parent_code",
|
|
118
|
+
kind="shop_discount_condition",
|
|
119
|
+
)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import Skeleton
|
|
5
|
+
from viur.shop.constants import *
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_payment_providers() -> dict[str, str]:
|
|
11
|
+
return {}
|
|
12
|
+
return shop.payment_providers # TODO
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class OrderSkel(Skeleton): # STATE: Complete (as in model)
|
|
16
|
+
kindName = "shop_order"
|
|
17
|
+
|
|
18
|
+
billing_address = RelationalBone(
|
|
19
|
+
descr="billing_address",
|
|
20
|
+
kind="shop_address",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
customer = RelationalBone(
|
|
24
|
+
descr="customer",
|
|
25
|
+
kind="user",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
cart = RelationalBone(
|
|
29
|
+
descr="cart",
|
|
30
|
+
kind="shop_cart_node",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
total = NumericBone(
|
|
34
|
+
descr="total",
|
|
35
|
+
precision=2,
|
|
36
|
+
min=0,
|
|
37
|
+
# TODO: UnitBone / CurrencyBone
|
|
38
|
+
)
|
|
39
|
+
"""Kopie der total vom gesamten Warenkorb"""
|
|
40
|
+
|
|
41
|
+
order_uid = StringBone(
|
|
42
|
+
descr="order_uid",
|
|
43
|
+
)
|
|
44
|
+
"""Bestellnummer"""
|
|
45
|
+
|
|
46
|
+
payment_provider = SelectBone(
|
|
47
|
+
descr="payment_provider",
|
|
48
|
+
values=get_payment_providers,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
is_ordered = BooleanBone(
|
|
52
|
+
descr="is_ordered",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
is_paid = BooleanBone(
|
|
56
|
+
descr="is_paid",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
is_rts = BooleanBone(
|
|
60
|
+
descr="is_rts",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
state = SelectBone(
|
|
64
|
+
descr="state",
|
|
65
|
+
values=OrderState,
|
|
66
|
+
multiple=True,
|
|
67
|
+
# compute=Compute(), #TODO:tbd; generate from is_* bones
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
email = EmailBone(
|
|
71
|
+
descr="email",
|
|
72
|
+
)
|
|
73
|
+
"""Kopieren von User oder Eingabe von Nutzer bei Gast"""
|
|
74
|
+
|
|
75
|
+
project_data = JsonBone(
|
|
76
|
+
descr="project_data",
|
|
77
|
+
)
|
|
78
|
+
"""Zusätzliche Daten vom Projekt für eine Bestellung.
|
|
79
|
+
Ggf. überlegen ob einzelne Bones durch Skeleton Modifizierung besser sind."""
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import Skeleton
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_suppliers() -> dict[str, str]:
|
|
10
|
+
return {}
|
|
11
|
+
return shop.configured_supliers # TODO
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ShippingSkel(Skeleton): # STATE: Complete (as in model)
|
|
15
|
+
kindName = "shop_shipping"
|
|
16
|
+
|
|
17
|
+
name = StringBone(
|
|
18
|
+
descr="Name",
|
|
19
|
+
)
|
|
20
|
+
"""DHL Standard, DHL Express, DPD-Shop, ..."""
|
|
21
|
+
|
|
22
|
+
description = TextBone(
|
|
23
|
+
descr="description",
|
|
24
|
+
validHtml=None,
|
|
25
|
+
)
|
|
26
|
+
"""
|
|
27
|
+
"Sie brauchen ein DHL-Kundenkonto"
|
|
28
|
+
"Du bist auf einer Insel"
|
|
29
|
+
...
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
shipping_cost = NumericBone(
|
|
33
|
+
descr="shipping_cost",
|
|
34
|
+
precision=2,
|
|
35
|
+
min=0,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
supplier = SelectBone(
|
|
39
|
+
descr="supplier",
|
|
40
|
+
values=get_suppliers,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
delivery_time_min = NumericBone(
|
|
44
|
+
descr="delivery_time_min",
|
|
45
|
+
min=0,
|
|
46
|
+
# TODO: UnitBone
|
|
47
|
+
)
|
|
48
|
+
"""Tag(e)"""
|
|
49
|
+
|
|
50
|
+
delivery_time_max = NumericBone(
|
|
51
|
+
descr="delivery_time_max",
|
|
52
|
+
min=0,
|
|
53
|
+
# TODO: UnitBone
|
|
54
|
+
)
|
|
55
|
+
"""Tag(e)"""
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import Skeleton
|
|
5
|
+
from .shipping_precondition import ShippingPreconditionRelSkel
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ShippingConfigSkel(Skeleton): # STATE: Complete (as in model)
|
|
11
|
+
name = StringBone(
|
|
12
|
+
descr="name",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
shipping_skel = RelationalBone(
|
|
16
|
+
descr="shipping_skel",
|
|
17
|
+
kind="shop_shipping",
|
|
18
|
+
using=ShippingPreconditionRelSkel,
|
|
19
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import RelSkel
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ShippingPreconditionRelSkel(RelSkel): # STATE: Complete (as in model)
|
|
10
|
+
minimum_order_value = NumericBone(
|
|
11
|
+
descr="minimum_order_value",
|
|
12
|
+
precision=2,
|
|
13
|
+
min=2,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
country = SelectCountryBone(
|
|
17
|
+
descr="country",
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
zip_code = StringBone(
|
|
21
|
+
descr="zip_code",
|
|
22
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from viur.core.bones import *
|
|
4
|
+
from viur.core.skeleton import Skeleton
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger("viur.shop").getChild(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class VatSkel(Skeleton): # STATE: Complete (as in model)
|
|
10
|
+
kindName = "shop_vat"
|
|
11
|
+
|
|
12
|
+
rate = NumericBone(
|
|
13
|
+
descr="rate",
|
|
14
|
+
precision=2,
|
|
15
|
+
min=0,
|
|
16
|
+
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This is the place where the viur-shop version number is defined;
|
|
2
|
+
# For pre-releases, postfix with ".betaN" or ".rcN" where `N` is an incremented number for each pre-release.
|
|
3
|
+
# This will mark it as a pre-release as well on PyPI.
|
|
4
|
+
# See CONTRIBUTING.md for further information. # TODO: tbd
|
|
5
|
+
|
|
6
|
+
__version__ = "0.1.0.dev2"
|
|
7
|
+
|
|
8
|
+
assert __version__.count(".") >= 2 and "".join(__version__.split(".", 3)[:3]).isdigit(), \
|
|
9
|
+
"Semantic __version__ expected!"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: viur-shop
|
|
3
|
+
Version: 0.1.0.dev2
|
|
4
|
+
Summary: A ViUR-shop
|
|
5
|
+
Home-page: https://github.com/viur-framework/viur-shop
|
|
6
|
+
Author: Sven Eberth
|
|
7
|
+
Author-email: se@mausbrand.de
|
|
8
|
+
Maintainer: Sven Eberth
|
|
9
|
+
Maintainer-email: se@mausbrand.de
|
|
10
|
+
Classifier: Development Status :: 1 - Planning
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
|
|
21
|
+
# viur-shop (WIP)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
setup.py
|
|
6
|
+
src/viur/shop/__init__.py
|
|
7
|
+
src/viur/shop/constants.py
|
|
8
|
+
src/viur/shop/shop.py
|
|
9
|
+
src/viur/shop/version.py
|
|
10
|
+
src/viur/shop/modules/__init__.py
|
|
11
|
+
src/viur/shop/modules/abstract.py
|
|
12
|
+
src/viur/shop/modules/api.py
|
|
13
|
+
src/viur/shop/modules/cart.py
|
|
14
|
+
src/viur/shop/payment_providers/__init__.py
|
|
15
|
+
src/viur/shop/payment_providers/abstract.py
|
|
16
|
+
src/viur/shop/skeletons/__init__.py
|
|
17
|
+
src/viur/shop/skeletons/address.py
|
|
18
|
+
src/viur/shop/skeletons/article.py
|
|
19
|
+
src/viur/shop/skeletons/cart.py
|
|
20
|
+
src/viur/shop/skeletons/discount.py
|
|
21
|
+
src/viur/shop/skeletons/discount_condition.py
|
|
22
|
+
src/viur/shop/skeletons/order.py
|
|
23
|
+
src/viur/shop/skeletons/shipping.py
|
|
24
|
+
src/viur/shop/skeletons/shipping_config.py
|
|
25
|
+
src/viur/shop/skeletons/shipping_precondition.py
|
|
26
|
+
src/viur/shop/skeletons/vat.py
|
|
27
|
+
src/viur_shop.egg-info/PKG-INFO
|
|
28
|
+
src/viur_shop.egg-info/SOURCES.txt
|
|
29
|
+
src/viur_shop.egg-info/dependency_links.txt
|
|
30
|
+
src/viur_shop.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
viur
|