django-spire 0.17.10__py3-none-any.whl → 0.17.11__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.
- django_spire/consts.py +1 -1
- django_spire/contrib/seeding/model/base.py +21 -20
- {django_spire-0.17.10.dist-info → django_spire-0.17.11.dist-info}/METADATA +2 -2
- {django_spire-0.17.10.dist-info → django_spire-0.17.11.dist-info}/RECORD +7 -7
- {django_spire-0.17.10.dist-info → django_spire-0.17.11.dist-info}/WHEEL +0 -0
- {django_spire-0.17.10.dist-info → django_spire-0.17.11.dist-info}/licenses/LICENSE.md +0 -0
- {django_spire-0.17.10.dist-info → django_spire-0.17.11.dist-info}/top_level.txt +0 -0
django_spire/consts.py
CHANGED
|
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|
|
2
2
|
|
|
3
3
|
from dandy.recorder import recorder_to_html_file
|
|
4
4
|
from dandy import SqliteCache
|
|
5
|
-
from dandy
|
|
5
|
+
from dandy import generate_cache_key
|
|
6
6
|
|
|
7
7
|
from django_spire.contrib.seeding.field.override import FieldOverride
|
|
8
8
|
from django_spire.contrib.seeding.model.config import FieldsConfig
|
|
@@ -22,7 +22,7 @@ class BaseModelSeeder(ABC):
|
|
|
22
22
|
fields = None
|
|
23
23
|
field_config_class = FieldsConfig
|
|
24
24
|
|
|
25
|
-
default_to =
|
|
25
|
+
default_to = 'llm'
|
|
26
26
|
|
|
27
27
|
cache_seed = True
|
|
28
28
|
cache_name = 'model_seeder'
|
|
@@ -40,16 +40,15 @@ class BaseModelSeeder(ABC):
|
|
|
40
40
|
@classmethod
|
|
41
41
|
def get_field_config(cls) -> FieldsConfig:
|
|
42
42
|
if cls._field_config is None:
|
|
43
|
-
|
|
44
43
|
if cls.model_class is None:
|
|
45
|
-
raise ValueError(
|
|
44
|
+
raise ValueError('model_class must be defined before using seeder.')
|
|
46
45
|
|
|
47
|
-
raw_fields = cls.__dict__.get(
|
|
46
|
+
raw_fields = cls.__dict__.get('fields', {})
|
|
48
47
|
cls._field_config = cls.field_config_class(
|
|
49
48
|
raw_fields=raw_fields,
|
|
50
49
|
field_names=cls.field_names(),
|
|
51
50
|
default_to=cls.default_to,
|
|
52
|
-
model_class=cls.model_class
|
|
51
|
+
model_class=cls.model_class,
|
|
53
52
|
)
|
|
54
53
|
return cls._field_config
|
|
55
54
|
|
|
@@ -69,18 +68,19 @@ class BaseModelSeeder(ABC):
|
|
|
69
68
|
@classmethod
|
|
70
69
|
@recorder_to_html_file('model_seeder')
|
|
71
70
|
def seed_data(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
cls,
|
|
72
|
+
count=1,
|
|
73
|
+
fields: dict | None = None,
|
|
75
74
|
) -> list[dict]:
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
field_config = (
|
|
76
|
+
cls.get_field_config().override(fields)
|
|
77
|
+
if fields
|
|
78
|
+
else cls.get_field_config()
|
|
79
|
+
)
|
|
78
80
|
|
|
79
81
|
if cls.cache_seed:
|
|
80
82
|
cache_key = generate_cache_key(
|
|
81
|
-
cls.seed_data,
|
|
82
|
-
count=count,
|
|
83
|
-
fields=field_config.fields
|
|
83
|
+
cls.seed_data, count=count, fields=field_config.fields
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
cache = SqliteCache(cache_name=cls.cache_name, limit=cls.cache_limit)
|
|
@@ -97,7 +97,9 @@ class BaseModelSeeder(ABC):
|
|
|
97
97
|
if len(seeder.seeder_fields) > 0:
|
|
98
98
|
seed_data.append(seeder.seed(cls, count))
|
|
99
99
|
|
|
100
|
-
formatted_seed_data = [
|
|
100
|
+
formatted_seed_data = [
|
|
101
|
+
{} for _ in range(max(len(sublist) for sublist in seed_data))
|
|
102
|
+
]
|
|
101
103
|
for sublist in seed_data:
|
|
102
104
|
for i, d in enumerate(sublist):
|
|
103
105
|
formatted_seed_data[i].update(d)
|
|
@@ -109,11 +111,10 @@ class BaseModelSeeder(ABC):
|
|
|
109
111
|
|
|
110
112
|
@classmethod
|
|
111
113
|
def seed(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
cls,
|
|
115
|
+
count: int = 1,
|
|
116
|
+
fields: dict | None = None,
|
|
115
117
|
) -> list:
|
|
116
118
|
return [
|
|
117
|
-
cls.model_class(**seed_data)
|
|
118
|
-
for seed_data in cls.seed_data(count, fields)
|
|
119
|
+
cls.model_class(**seed_data) for seed_data in cls.seed_data(count, fields)
|
|
119
120
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-spire
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.11
|
|
4
4
|
Summary: A project for Django Spire
|
|
5
5
|
Author-email: Brayden Carlson <braydenc@stratusadv.com>, Nathan Johnson <nathanj@stratusadv.com>
|
|
6
6
|
License: Copyright (c) 2024 Stratus Advanced Technologies and Contributors.
|
|
@@ -48,7 +48,7 @@ License-File: LICENSE.md
|
|
|
48
48
|
Requires-Dist: boto3>=1.34.0
|
|
49
49
|
Requires-Dist: botocore>=1.34.0
|
|
50
50
|
Requires-Dist: crispy-bootstrap5==2024.10
|
|
51
|
-
Requires-Dist: dandy
|
|
51
|
+
Requires-Dist: dandy>=1.2.1
|
|
52
52
|
Requires-Dist: django>=5.1.8
|
|
53
53
|
Requires-Dist: django-crispy-forms==2.3
|
|
54
54
|
Requires-Dist: django-glue>=0.8.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
django_spire/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
django_spire/conf.py,sha256=EYC1hXqYqheYrb_b6Q93LrSgNl91JV633E4N5j-KGTo,1012
|
|
3
|
-
django_spire/consts.py,sha256=
|
|
3
|
+
django_spire/consts.py,sha256=Bie71C5pHWjbYwTai1019M83OJOCxc-dh12K5Wsbbcw,391
|
|
4
4
|
django_spire/exceptions.py,sha256=L5ndRO5ftMmh0pHkO2z_NG3LSGZviJ-dDHNT73SzTNw,48
|
|
5
5
|
django_spire/settings.py,sha256=tGxgEri3TQRBaiwX7YRcWifMf_g1xv1RznplFR6zZnI,821
|
|
6
6
|
django_spire/urls.py,sha256=mKeZszb5U4iIGqddMb5Tt5fRC72U2wABEOi6mvOfEBU,656
|
|
@@ -377,7 +377,7 @@ django_spire/contrib/seeding/management/example.py,sha256=gVRnd5prEbIFgehoUOL8TM
|
|
|
377
377
|
django_spire/contrib/seeding/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
378
378
|
django_spire/contrib/seeding/management/commands/seeding.py,sha256=MQKYtw2HmoKbBfQAy_ajmxXgRTmzurmF__b0DE3v_wk,1617
|
|
379
379
|
django_spire/contrib/seeding/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
380
|
-
django_spire/contrib/seeding/model/base.py,sha256=
|
|
380
|
+
django_spire/contrib/seeding/model/base.py,sha256=7eNHVLIBk8PUymIkfkAoBZt_ziIGLfXFL1QsWTbxuu4,3232
|
|
381
381
|
django_spire/contrib/seeding/model/config.py,sha256=ithRH5Em1ixKCVRMGenQsdRaOGuS0BkNMIicsRWH1-c,2049
|
|
382
382
|
django_spire/contrib/seeding/model/enums.py,sha256=jLh6araHD6LrhzCvex8-xNQQLru2Y6XxjPKkiC0ISCo,129
|
|
383
383
|
django_spire/contrib/seeding/model/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -1105,8 +1105,8 @@ django_spire/theme/urls/page_urls.py,sha256=S8nkKkgbhG3XHI3uMUL-piOjXIrRkuY2UlM_
|
|
|
1105
1105
|
django_spire/theme/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1106
1106
|
django_spire/theme/views/json_views.py,sha256=W1khC2K_EMbEzAFmMxC_P76_MFnkRH4-eVdodrRfAhw,1904
|
|
1107
1107
|
django_spire/theme/views/page_views.py,sha256=pHr8iekjtR99xs7w1taj35HEo133Svq1dvDD0y0VL1c,3933
|
|
1108
|
-
django_spire-0.17.
|
|
1109
|
-
django_spire-0.17.
|
|
1110
|
-
django_spire-0.17.
|
|
1111
|
-
django_spire-0.17.
|
|
1112
|
-
django_spire-0.17.
|
|
1108
|
+
django_spire-0.17.11.dist-info/licenses/LICENSE.md,sha256=tlTbOtgKoy-xAQpUk9gPeh9O4oRXCOzoWdW3jJz0wnA,1091
|
|
1109
|
+
django_spire-0.17.11.dist-info/METADATA,sha256=9-OpANaoQUpUgf3TIP7ZjlIzPdhDYvj689KbwbZ1cuk,4937
|
|
1110
|
+
django_spire-0.17.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
1111
|
+
django_spire-0.17.11.dist-info/top_level.txt,sha256=xf3QV1e--ONkVpgMDQE9iqjQ1Vg4--_6C8wmO-KxPHQ,13
|
|
1112
|
+
django_spire-0.17.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|