Skip to content

Commit 3cb3714

Browse files
authored
feat: Make a bunch of bones searchable (#106)
Resolves #104
1 parent f559eb3 commit 3cb3714

File tree

10 files changed

+37
-12
lines changed

10 files changed

+37
-12
lines changed

src/viur/shop/skeletons/address.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from viur.core import conf, current, i18n
1+
from viur.core import conf, current
22
from viur.core.bones import *
33
from viur.core.skeleton import Skeleton
44
from viur.shop.types import *
@@ -18,6 +18,7 @@ class AddressSkel(Skeleton): # STATE: Complete (as in model)
1818
lambda skel: f'{skel["salutation"]} {skel["firstname"]} {skel["lastname"]}'.strip(),
1919
ComputeInterval(ComputeMethod.OnWrite),
2020
),
21+
searchable=True,
2122
)
2223

2324
customer_type = SelectBone(
@@ -36,30 +37,36 @@ class AddressSkel(Skeleton): # STATE: Complete (as in model)
3637

3738
company_name = StringBone(
3839
params={"group": "Customer Info"},
40+
searchable=True,
3941
)
4042

4143
firstname = StringBone(
4244
params={"group": "Customer Info"},
4345
required=True,
46+
searchable=True,
4447
)
4548

4649
lastname = StringBone(
4750
params={"group": "Customer Info"},
4851
required=True,
52+
searchable=True,
4953
)
5054

5155
street_name = StringBone(
5256
params={"group": "Customer Address"},
5357
required=True,
58+
searchable=True,
5459
)
5560

5661
street_number = StringBone(
5762
params={"group": "Customer Address"},
5863
required=True,
64+
searchable=True,
5965
)
6066

6167
address_addition = StringBone(
6268
params={"group": "Customer Address"},
69+
searchable=True,
6370
)
6471

6572
zip_code = StringBone(
@@ -75,16 +82,19 @@ class AddressSkel(Skeleton): # STATE: Complete (as in model)
7582
public=True,
7683
),
7784
},
85+
searchable=True,
7886
)
7987

8088
city = StringBone(
8189
params={"group": "Customer Address"},
8290
required=True,
91+
searchable=True,
8392
)
8493

8594
country = SelectCountryBone(
8695
params={"group": "Customer Address"},
8796
required=True,
97+
searchable=True,
8898
)
8999

90100
customer = RelationalBone(
@@ -106,6 +116,7 @@ class AddressSkel(Skeleton): # STATE: Complete (as in model)
106116
public=True,
107117
),
108118
},
119+
searchable=True,
109120
)
110121
"""Kopieren von User oder Eingabe von Nutzer bei Gast"""
111122

@@ -122,6 +133,7 @@ class AddressSkel(Skeleton): # STATE: Complete (as in model)
122133
public=True,
123134
),
124135
},
136+
searchable=True,
125137
)
126138

127139
# FIXME: What happens if an AddressSkel has both address_types and is_default

src/viur/shop/skeletons/article.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from viur.core import utils
66
from viur.core.bones import *
77
from viur.core.skeleton import BaseSkeleton
8-
98
from viur.shop.types import *
109
from ..globals import SHOP_INSTANCE, SHOP_LOGGER
1110
from ..types.response import make_json_dumpable

src/viur/shop/skeletons/cart.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,15 @@ class CartNodeSkel(TreeSkel): # STATE: Complete (as in model)
192192

193193
customer_comment = TextBone(
194194
validHtml=None,
195+
searchable=True,
195196
)
196197

197198
name = StringBone(
198199
defaultValue=lambda skel, bone: (
199200
f'Session Cart of {current.user.get() and current.user.get()["name"] or "__guest__"}'
200201
f' created at {utils.utcNow()}'
201-
)
202+
),
203+
searchable=True,
202204
)
203205

204206
cart_type = SelectBone(
@@ -265,6 +267,7 @@ class CartItemSkel(TreeSkel): # STATE: Complete (as in model)
265267
# --- Bones to store a frozen copy of the article values: -----------------
266268

267269
shop_name = StringBone(
270+
searchable=True,
268271
)
269272

270273
shop_description = TextBone(

src/viur/shop/skeletons/discount.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ class DiscountSkel(Skeleton): # STATE: Complete (as in model)
6161
]
6262

6363
name = StringBone(
64+
searchable=True,
6465
)
6566

6667
description = TextBone(
6768
validHtml=None,
69+
searchable=True,
6870
)
6971

7072
discount_type = SelectBone(

src/viur/shop/skeletons/discount_condition.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typing as t # noqa
22
from datetime import datetime as dt
33

4-
from viur.core import conf, i18n
4+
from viur.core import conf
55
from viur.core.bones import *
66
from viur.core.skeleton import Skeleton
77
from viur.shop.types import *
@@ -53,13 +53,15 @@ class DiscountConditionSkel(Skeleton): # STATE: Complete (as in model)
5353
params={
5454
"category": "1 – General",
5555
},
56+
searchable=True,
5657
)
5758

5859
description = TextBone(
5960
validHtml=None,
6061
params={
6162
"category": "1 – General",
6263
},
64+
searchable=True,
6365
)
6466

6567
code_type = SelectBone(
@@ -126,6 +128,7 @@ class DiscountConditionSkel(Skeleton): # STATE: Complete (as in model)
126128
},
127129
unique=UniqueValue(UniqueLockMethod.SameValue, False, "Code exist already"), # TODO
128130
caseSensitive=False,
131+
searchable=True,
129132
)
130133

131134
individual_codes_prefix = StringBone(
@@ -141,6 +144,7 @@ class DiscountConditionSkel(Skeleton): # STATE: Complete (as in model)
141144
),
142145
},
143146
unique=UniqueValue(UniqueLockMethod.SameValue, False, "Value already taken"),
147+
searchable=True,
144148
)
145149

146150
scope_minimum_order_value = NumericBone(

src/viur/shop/skeletons/order.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from viur.core.skeleton import Skeleton
66
from viur.shop.types import *
77
from ..globals import SHOP_INSTANCE, SHOP_LOGGER
8-
from deprecated import deprecated
98

109
logger = SHOP_LOGGER.getChild(__name__)
1110

@@ -31,10 +30,12 @@ class OrderSkel(Skeleton): # STATE: Complete (as in model)
3130
"email", "phone",
3231
"is_default", "address_type",
3332
],
33+
searchable=True,
3434
)
3535

3636
customer = RelationalBone(
3737
kind="user",
38+
searchable=True,
3839
)
3940

4041
cart = TreeNodeBone(
@@ -55,7 +56,8 @@ class OrderSkel(Skeleton): # STATE: Complete (as in model)
5556
"context": {
5657
"skelType": "node",
5758
},
58-
}
59+
},
60+
searchable=True,
5961
)
6062

6163
total = NumericBone(
@@ -66,7 +68,8 @@ class OrderSkel(Skeleton): # STATE: Complete (as in model)
6668
"""Kopie der total vom gesamten Warenkorb"""
6769

6870
order_uid = StringBone(
69-
unique=UniqueValue(UniqueLockMethod.SameValue, False, "UID must be unique")
71+
unique=UniqueValue(UniqueLockMethod.SameValue, False, "UID must be unique"),
72+
searchable=True,
7073
# TODO: UidBone
7174
)
7275
"""Bestellnummer"""

src/viur/shop/skeletons/shipping.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import typing as t # noqa
33

44
from viur.core.bones import *
5+
from viur.core.i18n import translate
56
from viur.core.skeleton import Skeleton
67
from ..globals import SHOP_INSTANCE, SHOP_LOGGER
7-
from viur.core.i18n import translate
88

99
logger = SHOP_LOGGER.getChild(__name__)
1010

@@ -32,6 +32,7 @@ class ShippingSkel(Skeleton): # STATE: Complete (as in model)
3232
kindName = "{{viur_shop_modulename}}_shipping"
3333

3434
name = StringBone(
35+
searchable=True,
3536
)
3637
"""DHL Standard, DHL Express, DPD-Shop, ..."""
3738

@@ -42,7 +43,8 @@ class ShippingSkel(Skeleton): # STATE: Complete (as in model)
4243
"viur.shop.skeleton.shipping.description.tooltip",
4344
public=True,
4445
),
45-
}
46+
},
47+
searchable=True,
4648
)
4749
"""
4850
"Sie brauchen ein DHL-Kundenkonto"

src/viur/shop/skeletons/shipping_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import typing as t # noqa
22

3-
from viur.core import db
43
from viur.core.bones import *
54
from viur.core.skeleton import Skeleton, SkeletonInstance
65
from .shipping_precondition import ShippingPreconditionRelSkel
@@ -13,6 +12,7 @@ class ShippingConfigSkel(Skeleton): # STATE: Complete (as in model)
1312
kindName = "{{viur_shop_modulename}}_shipping_config"
1413

1514
name = StringBone(
15+
searchable=True,
1616
)
1717

1818
shipping = RelationalBone(
@@ -29,6 +29,7 @@ class ShippingConfigSkel(Skeleton): # STATE: Complete (as in model)
2929
"art_no",
3030
"delivery_time_*",
3131
},
32+
searchable=True,
3233
)
3334

3435
@classmethod

src/viur/shop/skeletons/vat.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from calendar import c
21
import typing as t # noqa
32

43
from viur.core.bones import *
@@ -27,7 +26,6 @@ class VatSkel(RelSkel):
2726

2827

2928
class VatIncludedSkel(VatSkel):
30-
3129
value = NumericBone(
3230
required=True,
3331
precision=2,

src/viur/shop/skeletons/vat_rate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class VatRateSkel(Skeleton):
1919
)),
2020
ComputeInterval(ComputeMethod.OnWrite)
2121
),
22+
searchable=True,
2223
)
2324

2425
country = SelectCountryBone(

0 commit comments

Comments
 (0)