accrete 0.0.147__py3-none-any.whl → 0.0.148__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.
- accrete/contrib/ui/response.py +144 -74
- {accrete-0.0.147.dist-info → accrete-0.0.148.dist-info}/METADATA +1 -1
- {accrete-0.0.147.dist-info → accrete-0.0.148.dist-info}/RECORD +5 -5
- {accrete-0.0.147.dist-info → accrete-0.0.148.dist-info}/WHEEL +0 -0
- {accrete-0.0.147.dist-info → accrete-0.0.148.dist-info}/licenses/LICENSE +0 -0
accrete/contrib/ui/response.py
CHANGED
@@ -21,9 +21,12 @@ class Response:
|
|
21
21
|
def add_trigger(response):
|
22
22
|
pass
|
23
23
|
|
24
|
+
def get_context(self):
|
25
|
+
return self.context
|
26
|
+
|
24
27
|
def render(self, request) -> str:
|
25
28
|
return render_to_string(
|
26
|
-
template_name=self.template, context=self.
|
29
|
+
template_name=self.template, context=self.get_context(), request=request
|
27
30
|
)
|
28
31
|
|
29
32
|
def response(self, request, extra_content: str = None, replace_body: bool = False) -> HttpResponse:
|
@@ -47,11 +50,18 @@ class OobResponse(Response):
|
|
47
50
|
|
48
51
|
def __init__(self, *, template: str, context: dict, swap: str, tag: str = 'div'):
|
49
52
|
super().__init__(template=self.oob_template, context=context)
|
50
|
-
self.
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
self.include_template = template
|
54
|
+
self.swap = swap
|
55
|
+
self.tag = tag
|
56
|
+
|
57
|
+
def get_context(self):
|
58
|
+
context = super().get_context()
|
59
|
+
context.update({'oob': {
|
60
|
+
'template': self.include_template,
|
61
|
+
'swap': self.swap,
|
62
|
+
'tag': self.tag
|
54
63
|
}})
|
64
|
+
return context
|
55
65
|
|
56
66
|
|
57
67
|
class WindowResponse(Response):
|
@@ -68,20 +78,29 @@ class WindowResponse(Response):
|
|
68
78
|
is_centered: bool = False
|
69
79
|
):
|
70
80
|
super().__init__(template=self.base_template, context=context)
|
81
|
+
self.title = title
|
82
|
+
self.overview_template = overview_template
|
83
|
+
self.header_template = header_template
|
71
84
|
self.panel_template = panel_template
|
72
|
-
|
73
|
-
|
74
|
-
self.context.update({
|
75
|
-
'title': title,
|
76
|
-
'overview_template': overview_template,
|
77
|
-
'header_template': header_template,
|
78
|
-
'panel_template': panel_template,
|
79
|
-
'is_centered': is_centered
|
80
|
-
})
|
85
|
+
self.panel_template = panel_template
|
86
|
+
self.is_centered = is_centered
|
81
87
|
|
82
88
|
def _has_panel(self):
|
83
89
|
return bool(self.panel_template)
|
84
90
|
|
91
|
+
def get_context(self):
|
92
|
+
context = super().get_context()
|
93
|
+
if 'has_panel' not in context.keys():
|
94
|
+
context.update(has_panel=self._has_panel())
|
95
|
+
context.update({
|
96
|
+
'title': self.title,
|
97
|
+
'overview_template': self.overview_template,
|
98
|
+
'header_template': self.header_template,
|
99
|
+
'panel_template': self.panel_template,
|
100
|
+
'is_centered': self.is_centered
|
101
|
+
})
|
102
|
+
return context
|
103
|
+
|
85
104
|
def response(self, request, extra_content: str = None, replace_body: bool = True) -> HttpResponse:
|
86
105
|
return super().response(request, extra_content, replace_body)
|
87
106
|
|
@@ -101,38 +120,49 @@ class ListResponse(WindowResponse):
|
|
101
120
|
column_count: int = 1,
|
102
121
|
column_height: str = '150px',
|
103
122
|
overview_template: str = 'ui/list.html',
|
104
|
-
|
123
|
+
detail_header_template: str = None,
|
124
|
+
detail_data_template: str = None
|
105
125
|
):
|
106
126
|
assert page is not None or ui_filter is not None, _(
|
107
127
|
'Argument page or ui_filter must be supplied'
|
108
128
|
)
|
109
|
-
self.ui_filter = ui_filter
|
110
|
-
self.overview_template = overview_template
|
111
|
-
self.show_content_right = bool(detail_response)
|
112
129
|
super().__init__(
|
113
130
|
title=title,
|
114
131
|
context=context,
|
115
|
-
overview_template=
|
132
|
+
overview_template=overview_template,
|
116
133
|
header_template=header_template,
|
117
134
|
panel_template=panel_template,
|
118
135
|
)
|
119
|
-
|
120
|
-
|
121
|
-
self.
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
'show_content_right': str(self.show_content_right).lower()
|
129
|
-
})
|
130
|
-
if detail_response:
|
131
|
-
self.context.update(detail_response.context)
|
136
|
+
self.page = page or (ui_filter and ui_filter.get_page())
|
137
|
+
self.list_entry_template = list_entry_template
|
138
|
+
self.page = page
|
139
|
+
self.ui_filter = ui_filter
|
140
|
+
self.endless_scroll = endless_scroll
|
141
|
+
self.column_count = column_count
|
142
|
+
self.column_height = column_height
|
143
|
+
self.detail_header_template = detail_header_template
|
144
|
+
self.detail_data_template = detail_data_template
|
132
145
|
|
133
146
|
def _has_panel(self):
|
134
147
|
return bool(self.panel_template or self.ui_filter)
|
135
148
|
|
149
|
+
def get_context(self):
|
150
|
+
context = super().get_context()
|
151
|
+
context.update({
|
152
|
+
'list_entry_template': self.list_entry_template,
|
153
|
+
'page': self.page,
|
154
|
+
'ui_filter': self.ui_filter,
|
155
|
+
'endless_scroll': self.endless_scroll,
|
156
|
+
'column_count': self.column_count,
|
157
|
+
'column_height': self.column_height,
|
158
|
+
'detail_header_template': self.detail_header_template,
|
159
|
+
'detail_data_template': self.detail_data_template,
|
160
|
+
'show_content_right': str(bool(
|
161
|
+
self.detail_header_template or self.detail_data_template
|
162
|
+
)).lower(),
|
163
|
+
})
|
164
|
+
return context
|
165
|
+
|
136
166
|
def response(self, request, extra_content: str = None, replace_body: bool = False) -> HttpResponse:
|
137
167
|
return super().response(request, extra_content, replace_body)
|
138
168
|
|
@@ -151,15 +181,24 @@ class ListEntryResponse(Response):
|
|
151
181
|
column_count: int = 1,
|
152
182
|
column_height: str = '150px',
|
153
183
|
):
|
154
|
-
self.page = page
|
155
184
|
super().__init__(template=self.base_template, context=context or {})
|
156
|
-
self.
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
185
|
+
self.instance = instance
|
186
|
+
self.list_entry_template = list_entry_template
|
187
|
+
self.page = page
|
188
|
+
self.is_new = is_new
|
189
|
+
self.column_count = column_count
|
190
|
+
self.column_height = column_height
|
191
|
+
|
192
|
+
def get_context(self):
|
193
|
+
context = super().get_context()
|
194
|
+
context.update({
|
195
|
+
'instance': self.instance,
|
196
|
+
'list_entry_template': self.list_entry_template,
|
197
|
+
'is_new': self.is_new,
|
198
|
+
'column_count': self.column_count,
|
199
|
+
'column_height': self.column_height
|
162
200
|
})
|
201
|
+
return context
|
163
202
|
|
164
203
|
def render(self, request) -> str:
|
165
204
|
res = super().render(request)
|
@@ -188,36 +227,48 @@ class TableResponse(WindowResponse):
|
|
188
227
|
header_template: str = None,
|
189
228
|
panel_template: str = None,
|
190
229
|
overview_template: str = 'ui/table.html',
|
191
|
-
|
230
|
+
detail_header_template: str = None,
|
231
|
+
detail_data_template: str = None
|
192
232
|
):
|
193
233
|
assert page is not None or ui_filter is not None, _(
|
194
234
|
'Argument page or ui_filter must be supplied'
|
195
235
|
)
|
196
|
-
self.ui_filter = ui_filter
|
197
|
-
self.overview_template = overview_template
|
198
236
|
super().__init__(
|
199
237
|
title=title,
|
200
238
|
context=context,
|
201
|
-
overview_template=
|
239
|
+
overview_template=overview_template,
|
202
240
|
header_template=header_template,
|
203
241
|
panel_template=panel_template
|
204
242
|
)
|
205
|
-
|
206
|
-
|
207
|
-
self.
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
'footer': footer
|
214
|
-
})
|
215
|
-
if detail_response:
|
216
|
-
self.context.update(detail_response.context)
|
243
|
+
self.instance_label = instance_label
|
244
|
+
self.fields = fields
|
245
|
+
self.footer = footer
|
246
|
+
self.page = page or (ui_filter and ui_filter.get_page())
|
247
|
+
self.ui_filter = ui_filter
|
248
|
+
self.endless_scroll = endless_scroll
|
249
|
+
self.detail_header_template = detail_header_template
|
250
|
+
self.detail_data_template = detail_data_template
|
217
251
|
|
218
252
|
def _has_panel(self):
|
219
253
|
return bool(self.panel_template or self.ui_filter)
|
220
254
|
|
255
|
+
def get_context(self):
|
256
|
+
context = super().get_context()
|
257
|
+
context.update({
|
258
|
+
'page': self.page,
|
259
|
+
'ui_filter': self.ui_filter,
|
260
|
+
'endless_scroll': self.endless_scroll,
|
261
|
+
'fields': self.fields,
|
262
|
+
'instance_label': self.instance_label,
|
263
|
+
'footer': self.footer,
|
264
|
+
'detail_header_template': self.detail_header_template,
|
265
|
+
'detail_data_template': self.detail_data_template,
|
266
|
+
'show_content_right': str(bool(
|
267
|
+
self.detail_header_template or self.detail_data_template
|
268
|
+
)).lower()
|
269
|
+
})
|
270
|
+
return context
|
271
|
+
|
221
272
|
def response(self, request, extra_content: str = None, replace_body: bool = False) -> HttpResponse:
|
222
273
|
return super().response(request, extra_content, replace_body)
|
223
274
|
|
@@ -233,14 +284,21 @@ class TableRowResponse(Response):
|
|
233
284
|
footer: dict = None,
|
234
285
|
page: paginator.Page = None,
|
235
286
|
):
|
287
|
+
super().__init__(template=self.base_template, context={})
|
288
|
+
self.instance = instance
|
289
|
+
self.fields = fields
|
290
|
+
self.footer = footer
|
236
291
|
self.page = page
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
'
|
242
|
-
|
243
|
-
|
292
|
+
|
293
|
+
def get_context(self):
|
294
|
+
context = super().get_context()
|
295
|
+
context.update({
|
296
|
+
'instance': self.instance,
|
297
|
+
'fields': self.fields,
|
298
|
+
'footer': self.footer,
|
299
|
+
'page': self.page
|
300
|
+
})
|
301
|
+
return context
|
244
302
|
|
245
303
|
def render(self, request) -> str:
|
246
304
|
res = super().render(request)
|
@@ -267,15 +325,20 @@ class DetailResponse(Response):
|
|
267
325
|
super().__init__(template=self.base_template, context=context)
|
268
326
|
self.header_template = header_template
|
269
327
|
self.data_template = data_template
|
270
|
-
self.context.update(
|
271
|
-
'detail_header_template': header_template,
|
272
|
-
'detail_data_template': data_template
|
273
|
-
})
|
328
|
+
self.context.update()
|
274
329
|
|
275
330
|
@staticmethod
|
276
331
|
def add_trigger(response):
|
277
332
|
add_trigger(response, 'activate-detail')
|
278
333
|
|
334
|
+
def get_context(self):
|
335
|
+
context = super().get_context()
|
336
|
+
context.update({
|
337
|
+
'detail_header_template': self.header_template,
|
338
|
+
'detail_data_template': self.data_template
|
339
|
+
})
|
340
|
+
return context
|
341
|
+
|
279
342
|
|
280
343
|
class ModalResponse(Response):
|
281
344
|
|
@@ -291,13 +354,22 @@ class ModalResponse(Response):
|
|
291
354
|
|
292
355
|
):
|
293
356
|
super().__init__(template=template, context=context)
|
294
|
-
self.
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
357
|
+
self.modal_id = modal_id
|
358
|
+
self.title = title
|
359
|
+
self.is_update = is_update
|
360
|
+
self.is_blocking = is_blocking
|
361
|
+
self.modal_width = modal_width
|
362
|
+
|
363
|
+
def get_context(self):
|
364
|
+
context = super().get_context()
|
365
|
+
context.update({
|
366
|
+
'title': self.title,
|
367
|
+
'modal_id': re.sub(r'[^A-Za-z-]+', '', self.modal_id).strip('-'),
|
368
|
+
'is_update': self.is_update,
|
369
|
+
'is_blocking': self.is_blocking,
|
370
|
+
'modal_width': self.modal_width
|
300
371
|
})
|
372
|
+
return context
|
301
373
|
|
302
374
|
|
303
375
|
@dataclass
|
@@ -356,9 +428,7 @@ def add_trigger(
|
|
356
428
|
def update(request, ui_responses: list[Response]) -> HttpResponse:
|
357
429
|
response = HttpResponse()
|
358
430
|
content = ''
|
359
|
-
print(ui_responses)
|
360
431
|
for res in ui_responses:
|
361
|
-
print(res.context)
|
362
432
|
content += res.render(request)
|
363
433
|
res.add_trigger(response)
|
364
434
|
content += render_to_string('ui/message.html', request=request)
|
@@ -66,7 +66,7 @@ accrete/contrib/ui/apps.py,sha256=E0ao2ox6PQ3ldfeR17FXJUUJuGiWjm2DPCxHbPXGzls,15
|
|
66
66
|
accrete/contrib/ui/filter.py,sha256=WWELsSZF-v7FxAWw1gGvYHFBB0BhmQWuWacI_joTKas,13703
|
67
67
|
accrete/contrib/ui/middleware.py,sha256=QprWR8FXK9iMPIvLQAeYASaUJSW0uD9BHoYroMKrph0,1560
|
68
68
|
accrete/contrib/ui/models.py,sha256=Vjc0p2XbAPgE6HyTF6vll98A4eDhA5AvaQqsc4kQ9AQ,57
|
69
|
-
accrete/contrib/ui/response.py,sha256=
|
69
|
+
accrete/contrib/ui/response.py,sha256=dXc0G6HDg0CfQieumqQmaloYwLzd72LiMgRiNEKlG0g,13419
|
70
70
|
accrete/contrib/ui/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
71
71
|
accrete/contrib/ui/urls.py,sha256=5XUfK85HYWYf7oopMoJEEYmQ6pNgHgZBErBEn97pBt4,337
|
72
72
|
accrete/contrib/ui/views.py,sha256=5VUbP0jgMcLMv9-3AKxkV315RA0qXuw5PmTRejPc0Yg,1136
|
@@ -276,7 +276,7 @@ accrete/utils/forms.py,sha256=naV4urdfvmpxcx5Vf3Fo72M5Fy8DjGg5-vkysMKptbA,3914
|
|
276
276
|
accrete/utils/log.py,sha256=BH0MBDweAjx30wGBO4F3sFhbgkSoEs7T1lLLjlYZNnA,407
|
277
277
|
accrete/utils/models.py,sha256=2xTacvcpmDK_Bp4rAK7JdVLf8HU009LYNJ6eSpMgYZI,1014
|
278
278
|
accrete/utils/views.py,sha256=mHfcKNDOiq-38LQ6tz9pDPQt-xs03b2qMxwJClprqu8,5022
|
279
|
-
accrete-0.0.
|
280
|
-
accrete-0.0.
|
281
|
-
accrete-0.0.
|
282
|
-
accrete-0.0.
|
279
|
+
accrete-0.0.148.dist-info/METADATA,sha256=SLPaFIGp5oZTsazu0XIeEoAs1jzlZ4PJFz4-rVJT75s,4953
|
280
|
+
accrete-0.0.148.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
281
|
+
accrete-0.0.148.dist-info/licenses/LICENSE,sha256=vHwb4Qnv8UfYKFiCWyTuRGsi49x19UQwHRCky3b2_NE,1057
|
282
|
+
accrete-0.0.148.dist-info/RECORD,,
|
File without changes
|
File without changes
|