dsw-database 4.21.0__py2.py3-none-any.whl → 4.22.1__py2.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.
- dsw/database/build_info.py +4 -4
- dsw/database/database.py +46 -4
- dsw/database/model.py +50 -2
- {dsw_database-4.21.0.dist-info → dsw_database-4.22.1.dist-info}/METADATA +2 -2
- dsw_database-4.22.1.dist-info/RECORD +9 -0
- dsw_database-4.21.0.dist-info/RECORD +0 -9
- {dsw_database-4.21.0.dist-info → dsw_database-4.22.1.dist-info}/WHEEL +0 -0
- {dsw_database-4.21.0.dist-info → dsw_database-4.22.1.dist-info}/licenses/LICENSE +0 -0
- {dsw_database-4.21.0.dist-info → dsw_database-4.22.1.dist-info}/top_level.txt +0 -0
dsw/database/build_info.py
CHANGED
|
@@ -9,9 +9,9 @@ BuildInfo = namedtuple(
|
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
BUILD_INFO = BuildInfo(
|
|
12
|
-
version='v4.
|
|
13
|
-
built_at='2025-
|
|
14
|
-
sha='
|
|
12
|
+
version='v4.22.1~13699ca',
|
|
13
|
+
built_at='2025-09-04 06:55:38Z',
|
|
14
|
+
sha='13699ca0f74ff51a24bd76e242a89ef434b74658',
|
|
15
15
|
branch='HEAD',
|
|
16
|
-
tag='v4.
|
|
16
|
+
tag='v4.22.1',
|
|
17
17
|
)
|
dsw/database/database.py
CHANGED
|
@@ -15,7 +15,8 @@ from .model import DBDocumentTemplate, DBDocumentTemplateFile, \
|
|
|
15
15
|
DBDocumentTemplateAsset, DBDocument, DBComponent, \
|
|
16
16
|
DocumentState, DBTenantLimits, DBSubmission, \
|
|
17
17
|
DBInstanceConfigMail, DBQuestionnaireSimple, \
|
|
18
|
-
DBUserEntity, DBLocale
|
|
18
|
+
DBUserEntity, DBLocale, DBDocumentTemplateFormat, \
|
|
19
|
+
DBDocumentTemplateStep
|
|
19
20
|
|
|
20
21
|
LOG = logging.getLogger(__name__)
|
|
21
22
|
|
|
@@ -53,6 +54,10 @@ class Database:
|
|
|
53
54
|
'file_size = %s WHERE uuid = %s;')
|
|
54
55
|
SELECT_TEMPLATE = ('SELECT * FROM document_template '
|
|
55
56
|
'WHERE id = %s AND tenant_uuid = %s LIMIT 1;')
|
|
57
|
+
SELECT_TEMPLATE_FORMATS = ('SELECT * FROM document_template_format '
|
|
58
|
+
'WHERE document_template_id = %s AND tenant_uuid = %s;')
|
|
59
|
+
SELECT_TEMPLATE_STEPS = ('SELECT * FROM document_template_format_step '
|
|
60
|
+
'WHERE document_template_id = %s AND tenant_uuid = %s;')
|
|
56
61
|
SELECT_TEMPLATE_FILES = ('SELECT * FROM document_template_file '
|
|
57
62
|
'WHERE document_template_id = %s AND tenant_uuid = %s;')
|
|
58
63
|
SELECT_TEMPLATE_ASSETS = ('SELECT * FROM document_template_asset '
|
|
@@ -183,10 +188,47 @@ class Database:
|
|
|
183
188
|
query=self.SELECT_TEMPLATE,
|
|
184
189
|
params=(template_id, tenant_uuid),
|
|
185
190
|
)
|
|
186
|
-
|
|
187
|
-
if len(
|
|
191
|
+
dt_result = cursor.fetchall()
|
|
192
|
+
if len(dt_result) != 1:
|
|
188
193
|
return None
|
|
189
|
-
|
|
194
|
+
template = DBDocumentTemplate.from_dict_row(dt_result[0])
|
|
195
|
+
|
|
196
|
+
cursor.execute(
|
|
197
|
+
query=self.SELECT_TEMPLATE_FORMATS,
|
|
198
|
+
params=(template_id, tenant_uuid),
|
|
199
|
+
)
|
|
200
|
+
formats_result = cursor.fetchall()
|
|
201
|
+
formats = sorted([
|
|
202
|
+
DBDocumentTemplateFormat.from_dict_row(x) for x in formats_result
|
|
203
|
+
], key=lambda x: x.name)
|
|
204
|
+
cursor.execute(
|
|
205
|
+
query=self.SELECT_TEMPLATE_STEPS,
|
|
206
|
+
params=(template_id, tenant_uuid),
|
|
207
|
+
)
|
|
208
|
+
print(f'Format results: {formats_result}')
|
|
209
|
+
print(f'Formats: {formats}')
|
|
210
|
+
steps_result = cursor.fetchall()
|
|
211
|
+
steps = sorted([
|
|
212
|
+
DBDocumentTemplateStep.from_dict_row(x) for x in steps_result
|
|
213
|
+
], key=lambda x: x.position)
|
|
214
|
+
print(f'Steps results: {formats_result}')
|
|
215
|
+
print(f'Steps: {steps}')
|
|
216
|
+
steps_dict: dict[str, list[dict]] = {}
|
|
217
|
+
for step in steps:
|
|
218
|
+
if step.format_uuid not in steps_dict:
|
|
219
|
+
steps_dict[step.format_uuid] = []
|
|
220
|
+
steps_dict[step.format_uuid].append({
|
|
221
|
+
'name': step.name,
|
|
222
|
+
'options': step.options,
|
|
223
|
+
})
|
|
224
|
+
for format_obj in formats:
|
|
225
|
+
template.formats.append({
|
|
226
|
+
'uuid': format_obj.uuid,
|
|
227
|
+
'name': format_obj.name,
|
|
228
|
+
'steps': steps_dict.get(format_obj.uuid, []),
|
|
229
|
+
})
|
|
230
|
+
print(template.formats)
|
|
231
|
+
return template
|
|
190
232
|
|
|
191
233
|
@tenacity.retry(
|
|
192
234
|
reraise=True,
|
dsw/database/model.py
CHANGED
|
@@ -96,7 +96,7 @@ class DBDocumentTemplate:
|
|
|
96
96
|
readme: str
|
|
97
97
|
license: str
|
|
98
98
|
allowed_packages: dict
|
|
99
|
-
formats:
|
|
99
|
+
formats: list
|
|
100
100
|
phase: str
|
|
101
101
|
created_at: datetime.datetime
|
|
102
102
|
updated_at: datetime.datetime
|
|
@@ -127,7 +127,7 @@ class DBDocumentTemplate:
|
|
|
127
127
|
readme=data['readme'],
|
|
128
128
|
license=data['license'],
|
|
129
129
|
allowed_packages=data['allowed_packages'],
|
|
130
|
-
formats=
|
|
130
|
+
formats=[],
|
|
131
131
|
phase=data['phase'],
|
|
132
132
|
created_at=data['created_at'],
|
|
133
133
|
updated_at=data['updated_at'],
|
|
@@ -135,6 +135,54 @@ class DBDocumentTemplate:
|
|
|
135
135
|
)
|
|
136
136
|
|
|
137
137
|
|
|
138
|
+
@dataclasses.dataclass
|
|
139
|
+
class DBDocumentTemplateFormat:
|
|
140
|
+
document_template_id: str
|
|
141
|
+
uuid: str
|
|
142
|
+
name: str
|
|
143
|
+
icon: str
|
|
144
|
+
created_at: datetime.datetime
|
|
145
|
+
updated_at: datetime.datetime
|
|
146
|
+
tenant_uuid: str
|
|
147
|
+
|
|
148
|
+
@staticmethod
|
|
149
|
+
def from_dict_row(data: dict) -> 'DBDocumentTemplateFormat':
|
|
150
|
+
return DBDocumentTemplateFormat(
|
|
151
|
+
document_template_id=data['document_template_id'],
|
|
152
|
+
uuid=str(data['uuid']),
|
|
153
|
+
name=data['name'],
|
|
154
|
+
icon=data['icon'],
|
|
155
|
+
created_at=data['created_at'],
|
|
156
|
+
updated_at=data['updated_at'],
|
|
157
|
+
tenant_uuid=str(data.get('tenant_uuid', NULL_UUID)),
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
@dataclasses.dataclass
|
|
162
|
+
class DBDocumentTemplateStep:
|
|
163
|
+
document_template_id: str
|
|
164
|
+
format_uuid: str
|
|
165
|
+
position: int
|
|
166
|
+
name: str
|
|
167
|
+
options: dict[str, str]
|
|
168
|
+
created_at: datetime.datetime
|
|
169
|
+
updated_at: datetime.datetime
|
|
170
|
+
tenant_uuid: str
|
|
171
|
+
|
|
172
|
+
@staticmethod
|
|
173
|
+
def from_dict_row(data: dict) -> 'DBDocumentTemplateStep':
|
|
174
|
+
return DBDocumentTemplateStep(
|
|
175
|
+
document_template_id=data['document_template_id'],
|
|
176
|
+
format_uuid=str(data['format_uuid']),
|
|
177
|
+
position=data['position'],
|
|
178
|
+
name=data['name'],
|
|
179
|
+
options=data['options'],
|
|
180
|
+
created_at=data['created_at'],
|
|
181
|
+
updated_at=data['updated_at'],
|
|
182
|
+
tenant_uuid=str(data.get('tenant_uuid', NULL_UUID)),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
138
186
|
@dataclasses.dataclass
|
|
139
187
|
class DBDocumentTemplateFile:
|
|
140
188
|
document_template_id: str
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dsw-database
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.22.1
|
|
4
4
|
Summary: Library for managing DSW database
|
|
5
5
|
Author-email: Marek Suchánek <marek.suchanek@ds-wizard.org>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: psycopg[binary]
|
|
22
22
|
Requires-Dist: tenacity
|
|
23
|
-
Requires-Dist: dsw-config==4.
|
|
23
|
+
Requires-Dist: dsw-config==4.22.1
|
|
24
24
|
Dynamic: license-file
|
|
25
25
|
|
|
26
26
|
# Data Stewardship Wizard: Database
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
dsw/database/__init__.py,sha256=58ZXZ8i4xzAvvjUdqt8lvdv28hD0yzY_xxI6n9deynw,55
|
|
2
|
+
dsw/database/build_info.py,sha256=EYLCpP8X3b4D2wxL-L3_ziK0cah1lLSmcvV4I5kHHJw,381
|
|
3
|
+
dsw/database/database.py,sha256=2hXcU-txscH6qtKz1CT_JHIChdH4G_PgSNcIA6s4Tv8,27457
|
|
4
|
+
dsw/database/model.py,sha256=ECUNCxbzRuy8dPjEWY1dAkaY1AmdobH6DPGBQPZaaKY,13552
|
|
5
|
+
dsw_database-4.22.1.dist-info/licenses/LICENSE,sha256=rDtJ4LdsXvf_euOpGD0Q86P78K4JyM5m4yfYz9wZ750,11346
|
|
6
|
+
dsw_database-4.22.1.dist-info/METADATA,sha256=pkqNaqPyQI0Xs8YF08Dif4H-TJXtF8vAsBciMC5Rphk,1843
|
|
7
|
+
dsw_database-4.22.1.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
|
8
|
+
dsw_database-4.22.1.dist-info/top_level.txt,sha256=7SfbsHFoJ_vlAgG6C-xzETETwYO71dBrGnod8uMFnjw,4
|
|
9
|
+
dsw_database-4.22.1.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
dsw/database/__init__.py,sha256=58ZXZ8i4xzAvvjUdqt8lvdv28hD0yzY_xxI6n9deynw,55
|
|
2
|
-
dsw/database/build_info.py,sha256=eFSPWhQCrCiH6Lcl8PdY7XJvx3e2H0n9wIz0o4qYFlA,381
|
|
3
|
-
dsw/database/database.py,sha256=SrN4VN3-LDUUVVvm43sz9D36X8IjEIUbQuMS1Q1KbM8,25535
|
|
4
|
-
dsw/database/model.py,sha256=E2s0pJX4nzIOiOXZbnS5BqRhnZJtDFe6ZSY7kkalQ5M,12143
|
|
5
|
-
dsw_database-4.21.0.dist-info/licenses/LICENSE,sha256=rDtJ4LdsXvf_euOpGD0Q86P78K4JyM5m4yfYz9wZ750,11346
|
|
6
|
-
dsw_database-4.21.0.dist-info/METADATA,sha256=H_6D1uc1bbJUfv3aOy916KsPG6XGPL1E0k8bOpZV8PE,1843
|
|
7
|
-
dsw_database-4.21.0.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
|
8
|
-
dsw_database-4.21.0.dist-info/top_level.txt,sha256=7SfbsHFoJ_vlAgG6C-xzETETwYO71dBrGnod8uMFnjw,4
|
|
9
|
-
dsw_database-4.21.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|