accrete 0.0.10__py3-none-any.whl → 0.0.23__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/sequence/forms.py +2 -2
- accrete/contrib/sequence/queries.py +3 -4
- accrete/contrib/ui/__init__.py +11 -5
- accrete/contrib/ui/components.py +49 -0
- accrete/contrib/ui/context.py +284 -0
- accrete/contrib/ui/filter.py +22 -17
- accrete/contrib/ui/querystring.py +93 -0
- accrete/contrib/ui/static/bulma/LICENSE +21 -0
- accrete/contrib/ui/static/bulma/README.md +139 -0
- accrete/contrib/ui/static/bulma/bulma.sass +10 -0
- accrete/contrib/ui/static/bulma/css/bulma-rtl.css +11851 -0
- accrete/contrib/ui/static/bulma/css/bulma-rtl.css.map +1 -0
- accrete/contrib/ui/static/bulma/css/bulma-rtl.min.css +1 -0
- accrete/contrib/ui/static/bulma/css/bulma.css +11851 -0
- accrete/contrib/ui/static/bulma/css/bulma.css.map +1 -0
- accrete/contrib/ui/static/bulma/css/bulma.min.css +1 -0
- accrete/contrib/ui/static/bulma/package.json +56 -0
- accrete/contrib/ui/static/bulma/sass/base/_all.sass +6 -0
- accrete/contrib/ui/static/bulma/sass/base/animations.sass +5 -0
- accrete/contrib/ui/static/bulma/sass/base/generic.sass +145 -0
- accrete/contrib/ui/static/bulma/sass/base/helpers.sass +1 -0
- accrete/contrib/ui/static/bulma/sass/base/minireset.sass +79 -0
- accrete/contrib/ui/static/bulma/sass/components/_all.sass +15 -0
- accrete/contrib/ui/static/bulma/sass/components/breadcrumb.sass +77 -0
- accrete/contrib/ui/static/bulma/sass/components/card.sass +103 -0
- accrete/contrib/ui/static/bulma/sass/components/dropdown.sass +83 -0
- accrete/contrib/ui/static/bulma/sass/components/level.sass +79 -0
- accrete/contrib/ui/static/bulma/sass/components/media.sass +59 -0
- accrete/contrib/ui/static/bulma/sass/components/menu.sass +59 -0
- accrete/contrib/ui/static/bulma/sass/components/message.sass +101 -0
- accrete/contrib/ui/static/bulma/sass/components/modal.sass +117 -0
- accrete/contrib/ui/static/bulma/sass/components/navbar.sass +446 -0
- accrete/contrib/ui/static/bulma/sass/components/pagination.sass +167 -0
- accrete/contrib/ui/static/bulma/sass/components/panel.sass +121 -0
- accrete/contrib/ui/static/bulma/sass/components/tabs.sass +176 -0
- accrete/contrib/ui/static/bulma/sass/elements/_all.sass +16 -0
- accrete/contrib/ui/static/bulma/sass/elements/box.sass +26 -0
- accrete/contrib/ui/static/bulma/sass/elements/button.sass +357 -0
- accrete/contrib/ui/static/bulma/sass/elements/container.sass +29 -0
- accrete/contrib/ui/static/bulma/sass/elements/content.sass +162 -0
- accrete/contrib/ui/static/bulma/sass/elements/form.sass +1 -0
- accrete/contrib/ui/static/bulma/sass/elements/icon.sass +46 -0
- accrete/contrib/ui/static/bulma/sass/elements/image.sass +73 -0
- accrete/contrib/ui/static/bulma/sass/elements/notification.sass +52 -0
- accrete/contrib/ui/static/bulma/sass/elements/other.sass +31 -0
- accrete/contrib/ui/static/bulma/sass/elements/progress.sass +73 -0
- accrete/contrib/ui/static/bulma/sass/elements/table.sass +134 -0
- accrete/contrib/ui/static/bulma/sass/elements/tag.sass +140 -0
- accrete/contrib/ui/static/bulma/sass/elements/title.sass +70 -0
- accrete/contrib/ui/static/bulma/sass/form/_all.sass +9 -0
- accrete/contrib/ui/static/bulma/sass/form/checkbox-radio.sass +22 -0
- accrete/contrib/ui/static/bulma/sass/form/file.sass +184 -0
- accrete/contrib/ui/static/bulma/sass/form/input-textarea.sass +66 -0
- accrete/contrib/ui/static/bulma/sass/form/select.sass +88 -0
- accrete/contrib/ui/static/bulma/sass/form/shared.sass +60 -0
- accrete/contrib/ui/static/bulma/sass/form/tools.sass +215 -0
- accrete/contrib/ui/static/bulma/sass/grid/_all.sass +5 -0
- accrete/contrib/ui/static/bulma/sass/grid/columns.sass +513 -0
- accrete/contrib/ui/static/bulma/sass/grid/tiles.sass +36 -0
- accrete/contrib/ui/static/bulma/sass/helpers/_all.sass +12 -0
- accrete/contrib/ui/static/bulma/sass/helpers/color.sass +39 -0
- accrete/contrib/ui/static/bulma/sass/helpers/flexbox.sass +35 -0
- accrete/contrib/ui/static/bulma/sass/helpers/float.sass +10 -0
- accrete/contrib/ui/static/bulma/sass/helpers/other.sass +14 -0
- accrete/contrib/ui/static/bulma/sass/helpers/overflow.sass +2 -0
- accrete/contrib/ui/static/bulma/sass/helpers/position.sass +7 -0
- accrete/contrib/ui/static/bulma/sass/helpers/spacing.sass +31 -0
- accrete/contrib/ui/static/bulma/sass/helpers/typography.sass +103 -0
- accrete/contrib/ui/static/bulma/sass/helpers/visibility.sass +122 -0
- accrete/contrib/ui/static/bulma/sass/layout/_all.sass +6 -0
- accrete/contrib/ui/static/bulma/sass/layout/footer.sass +11 -0
- accrete/contrib/ui/static/bulma/sass/layout/hero.sass +153 -0
- accrete/contrib/ui/static/bulma/sass/layout/section.sass +17 -0
- accrete/contrib/ui/static/bulma/sass/utilities/_all.sass +9 -0
- accrete/contrib/ui/static/bulma/sass/utilities/animations.sass +1 -0
- accrete/contrib/ui/static/bulma/sass/utilities/controls.sass +49 -0
- accrete/contrib/ui/static/bulma/sass/utilities/derived-variables.sass +114 -0
- accrete/contrib/ui/static/bulma/sass/utilities/extends.sass +25 -0
- accrete/contrib/ui/static/bulma/sass/utilities/functions.sass +135 -0
- accrete/contrib/ui/static/bulma/sass/utilities/initial-variables.sass +79 -0
- accrete/contrib/ui/static/bulma/sass/utilities/mixins.sass +303 -0
- accrete/contrib/ui/static/css/accrete.css +10426 -79
- accrete/contrib/ui/static/css/accrete.css.bak +156 -0
- accrete/contrib/ui/static/css/accrete.css.map +1 -0
- accrete/contrib/ui/static/css/accrete.scss +232 -0
- accrete/contrib/ui/static/css/icons.css +9 -0
- accrete/contrib/ui/static/js/filter.js +129 -57
- accrete/contrib/ui/templates/ui/detail.html +1 -3
- accrete/contrib/ui/templates/ui/layout.html +37 -20
- accrete/contrib/ui/templates/ui/list.html +3 -3
- accrete/contrib/ui/templates/ui/partials/filter.html +10 -5
- accrete/contrib/ui/templates/ui/partials/header.html +5 -16
- accrete/contrib/ui/templates/ui/partials/pagination_detail.html +7 -11
- accrete/contrib/ui/templates/ui/partials/pagination_list.html +8 -10
- accrete/contrib/ui/templates/ui/partials/table_field.html +15 -0
- accrete/contrib/ui/templates/ui/partials/table_field_float.html +1 -0
- accrete/contrib/ui/templates/ui/partials/table_field_monetary.html +4 -0
- accrete/contrib/ui/templates/ui/partials/table_field_string.html +1 -0
- accrete/contrib/ui/templates/ui/table.html +20 -5
- accrete/contrib/ui/templatetags/accrete_ui.py +5 -3
- accrete/contrib/user/forms.py +28 -0
- accrete/contrib/user/models.py +16 -0
- accrete/contrib/user/templates/user/accrete_navbar_end.html +9 -0
- accrete/contrib/user/templates/user/user_detail.html +43 -0
- accrete/contrib/user/templates/user/user_form.html +56 -0
- accrete/contrib/user/urls.py +3 -1
- accrete/contrib/user/views.py +35 -3
- accrete/queries.py +5 -1
- {accrete-0.0.10.dist-info → accrete-0.0.23.dist-info}/METADATA +1 -1
- accrete-0.0.23.dist-info/RECORD +194 -0
- accrete/contrib/ui/helper.py +0 -417
- accrete-0.0.10.dist-info/RECORD +0 -107
- {accrete-0.0.10.dist-info → accrete-0.0.23.dist-info}/WHEEL +0 -0
- {accrete-0.0.10.dist-info → accrete-0.0.23.dist-info}/licenses/LICENSE +0 -0
accrete/contrib/ui/helper.py
DELETED
@@ -1,417 +0,0 @@
|
|
1
|
-
import datetime
|
2
|
-
import logging
|
3
|
-
import json
|
4
|
-
from dataclasses import dataclass, field
|
5
|
-
from django.db.models.functions import Lower
|
6
|
-
from django.db.models import Model, QuerySet, Q, CharField, Manager
|
7
|
-
from django.utils.translation import gettext_lazy as _
|
8
|
-
from django.core.exceptions import FieldDoesNotExist
|
9
|
-
from django.core.paginator import Paginator
|
10
|
-
from accrete.contrib.ui.filter import Filter
|
11
|
-
|
12
|
-
_logger = logging.getLogger(__name__)
|
13
|
-
|
14
|
-
|
15
|
-
@dataclass
|
16
|
-
class ClientAction:
|
17
|
-
|
18
|
-
name: str
|
19
|
-
url: str = ''
|
20
|
-
query_params: str = ''
|
21
|
-
attrs: list[str] = field(default_factory=list)
|
22
|
-
submit: bool = False
|
23
|
-
form_id: str = 'form'
|
24
|
-
class_list: list = field(default_factory=list)
|
25
|
-
|
26
|
-
|
27
|
-
@dataclass
|
28
|
-
class BreadCrumb:
|
29
|
-
|
30
|
-
name: str
|
31
|
-
url: str
|
32
|
-
|
33
|
-
|
34
|
-
@dataclass
|
35
|
-
class TableField:
|
36
|
-
|
37
|
-
label: str
|
38
|
-
name: str
|
39
|
-
|
40
|
-
|
41
|
-
@dataclass
|
42
|
-
class ListContext:
|
43
|
-
|
44
|
-
model: type[Model]
|
45
|
-
get_params: dict
|
46
|
-
title: str = None
|
47
|
-
context: dict = field(default_factory=dict)
|
48
|
-
queryset: QuerySet = None
|
49
|
-
extra_query: Q = None
|
50
|
-
related_fields: list[str] = field(default_factory=list)
|
51
|
-
prefetch_fields: list[str] = field(default_factory=list)
|
52
|
-
paginate_by: int = 20
|
53
|
-
order_by: list[str] = None
|
54
|
-
column_width: int = 12
|
55
|
-
filter_relation_depth: int = 4
|
56
|
-
actions: list[ClientAction] = field(default_factory=list)
|
57
|
-
breadcrumbs: list[BreadCrumb] = field(default_factory=list)
|
58
|
-
obj_label: str = 'Name'
|
59
|
-
fields: list[TableField] = field(default_factory=list)
|
60
|
-
|
61
|
-
def get_queryset(self):
|
62
|
-
order = self.get_order()
|
63
|
-
if isinstance(order, str):
|
64
|
-
if order == 'None':
|
65
|
-
order = None
|
66
|
-
return (self.queryset or queryset_from_querystring(
|
67
|
-
self.model, self.get_params.get('q', '[]'), order)
|
68
|
-
.filter(self.extra_query or Q())
|
69
|
-
.select_related(*self.related_fields)
|
70
|
-
.prefetch_related(*self.prefetch_fields)
|
71
|
-
.distinct())
|
72
|
-
|
73
|
-
def get_page_number(self, paginator):
|
74
|
-
page_number = self.get_params.get('page', '1')
|
75
|
-
|
76
|
-
try:
|
77
|
-
page_number = int(page_number)
|
78
|
-
except ValueError:
|
79
|
-
page_number = 1
|
80
|
-
|
81
|
-
if page_number < 1:
|
82
|
-
page_number = 1
|
83
|
-
elif page_number > paginator.num_pages:
|
84
|
-
page_number = paginator.num_pages
|
85
|
-
return page_number
|
86
|
-
|
87
|
-
def get_order(self):
|
88
|
-
return self.get_params.get('order_by', None) or self.order_by
|
89
|
-
|
90
|
-
def get_paginate_by(self):
|
91
|
-
paginate_by = self.get_params.get('paginate_by', self.paginate_by)
|
92
|
-
try:
|
93
|
-
paginate_by = int(paginate_by)
|
94
|
-
except ValueError:
|
95
|
-
paginate_by = self.paginate_by
|
96
|
-
return paginate_by
|
97
|
-
|
98
|
-
def get_context(self):
|
99
|
-
paginate_by = self.get_paginate_by()
|
100
|
-
paginator = Paginator(self.get_queryset(), paginate_by)
|
101
|
-
page = paginator.page(self.get_page_number(paginator))
|
102
|
-
context = {
|
103
|
-
'paginate_by': paginate_by,
|
104
|
-
'order_by': self.get_params.get('order_by', self.model._meta.ordering),
|
105
|
-
'paginator': paginator,
|
106
|
-
'page': page,
|
107
|
-
'list_pagination': True,
|
108
|
-
'column_width': self.column_width,
|
109
|
-
'title': self.title or self.model._meta.verbose_name_plural,
|
110
|
-
'filter_terms': Filter(self.model, self.filter_relation_depth).get_query_terms(),
|
111
|
-
'view_type': 'list',
|
112
|
-
'breadcrumbs': self.breadcrumbs,
|
113
|
-
'querystring': build_querystring(self.get_params),
|
114
|
-
'actions': self.actions,
|
115
|
-
'obj_label': self.obj_label,
|
116
|
-
'fields': self.fields
|
117
|
-
}
|
118
|
-
context.update(self.context)
|
119
|
-
return context
|
120
|
-
|
121
|
-
|
122
|
-
@dataclass
|
123
|
-
class DetailContext:
|
124
|
-
|
125
|
-
obj: Model
|
126
|
-
get_params: dict
|
127
|
-
order_by: str = None
|
128
|
-
paginate_by: int = 20
|
129
|
-
title: str = None
|
130
|
-
queryset: type[QuerySet] = None
|
131
|
-
extra_query: Q = None
|
132
|
-
related_fields: list[str] = field(default_factory=list)
|
133
|
-
prefetch_fields: list[str] = field(default_factory=list)
|
134
|
-
actions: list[ClientAction] = field(default_factory=list)
|
135
|
-
breadcrumbs: list[BreadCrumb] = field(default_factory=list),
|
136
|
-
context: dict = field(default_factory=dict)
|
137
|
-
|
138
|
-
def get_queryset(self):
|
139
|
-
order = self.get_order()
|
140
|
-
if isinstance(order, str):
|
141
|
-
if order == 'None':
|
142
|
-
order = None
|
143
|
-
return (self.queryset or queryset_from_querystring(
|
144
|
-
self.obj._meta.model, self.get_params.get('q', '[]'), order)
|
145
|
-
.filter(self.extra_query or Q())
|
146
|
-
.select_related(*self.related_fields)
|
147
|
-
.prefetch_related(*self.prefetch_fields)
|
148
|
-
.distinct())
|
149
|
-
|
150
|
-
def get_order(self):
|
151
|
-
return self.get_params.get('order_by', None) or self.order_by
|
152
|
-
|
153
|
-
def get_paginate_by(self):
|
154
|
-
paginate_by = self.get_params.get('paginate_by', self.paginate_by)
|
155
|
-
try:
|
156
|
-
paginate_by = int(paginate_by)
|
157
|
-
except ValueError:
|
158
|
-
paginate_by = self.paginate_by
|
159
|
-
return paginate_by
|
160
|
-
|
161
|
-
def get_pagination_context(self):
|
162
|
-
if not hasattr(self.obj, 'get_absolute_url'):
|
163
|
-
_logger.warning(
|
164
|
-
'Detail pagination disabled for models without the '
|
165
|
-
'get_absolute_url attribute. Set paginate_by to 0 to '
|
166
|
-
'deactivate pagination.'
|
167
|
-
)
|
168
|
-
return {}
|
169
|
-
queryset = self.get_queryset()
|
170
|
-
idx = (*queryset,).index(self.obj)
|
171
|
-
previous_object_url = (
|
172
|
-
queryset[idx - 1] if idx - 1 >= 0 else queryset.last()
|
173
|
-
).get_absolute_url()
|
174
|
-
next_object_url = (
|
175
|
-
queryset[idx + 1] if idx + 1 <= queryset.count() - 1 else queryset.first()
|
176
|
-
).get_absolute_url()
|
177
|
-
ctx = {
|
178
|
-
'previous_object_url': previous_object_url,
|
179
|
-
'next_object_url': next_object_url,
|
180
|
-
'current_object_idx': idx + 1,
|
181
|
-
'total_objects': queryset.count(),
|
182
|
-
'detail_pagination': True
|
183
|
-
}
|
184
|
-
return ctx
|
185
|
-
|
186
|
-
def get_context(self):
|
187
|
-
paginate_by = self.get_paginate_by()
|
188
|
-
ctx = {
|
189
|
-
'object': self.obj,
|
190
|
-
'title': self.title or self.obj,
|
191
|
-
'order_by': self.get_params.get('order_by', self.obj._meta.model._meta.ordering),
|
192
|
-
'paginate_by': paginate_by,
|
193
|
-
'detail_pagination': False,
|
194
|
-
'view_type': 'detail',
|
195
|
-
'breadcrumbs': self.breadcrumbs,
|
196
|
-
'querystring': build_querystring(self.get_params, ['page']),
|
197
|
-
'actions': self.actions
|
198
|
-
}
|
199
|
-
if self.paginate_by > 0:
|
200
|
-
ctx.update(self.get_pagination_context())
|
201
|
-
ctx.update(self.context)
|
202
|
-
return ctx
|
203
|
-
|
204
|
-
|
205
|
-
@dataclass
|
206
|
-
class FormContext:
|
207
|
-
|
208
|
-
model: Model|type[Model]
|
209
|
-
get_params: dict
|
210
|
-
title: str = None
|
211
|
-
context: dict = field(default_factory=dict)
|
212
|
-
form_id: str = 'form'
|
213
|
-
add_default_actions: bool = True
|
214
|
-
discard_url: str = None
|
215
|
-
actions: list[ClientAction] = field(default_factory=list)
|
216
|
-
|
217
|
-
def get_default_form_actions(self):
|
218
|
-
actions = [
|
219
|
-
ClientAction(
|
220
|
-
name=_('Save'),
|
221
|
-
submit=True,
|
222
|
-
class_list=['is-success'],
|
223
|
-
form_id=self.form_id
|
224
|
-
)
|
225
|
-
]
|
226
|
-
try:
|
227
|
-
url = self.discard_url or self.model.get_absolute_url()
|
228
|
-
except TypeError as e:
|
229
|
-
_logger.exception(
|
230
|
-
'Supply the discard_url parameter if FormContext is called '
|
231
|
-
'with a model class instead of an instance.'
|
232
|
-
)
|
233
|
-
raise e
|
234
|
-
except AttributeError as e:
|
235
|
-
_logger.error(
|
236
|
-
'Supply the discard_url parameter if FormContext is '
|
237
|
-
'called with a model instance that has the get_absolute_url '
|
238
|
-
'method not defined.'
|
239
|
-
)
|
240
|
-
raise e
|
241
|
-
|
242
|
-
actions.append(
|
243
|
-
ClientAction(
|
244
|
-
name=_('Discard'),
|
245
|
-
url=url
|
246
|
-
)
|
247
|
-
)
|
248
|
-
return actions
|
249
|
-
|
250
|
-
def get_title(self):
|
251
|
-
if self.title:
|
252
|
-
return self.title
|
253
|
-
try:
|
254
|
-
int(self.model.pk)
|
255
|
-
return f'Edit {self.model}'
|
256
|
-
except TypeError:
|
257
|
-
return f'Add {self.model._meta.verbose_name}'
|
258
|
-
|
259
|
-
def get_context(self):
|
260
|
-
ctx = {
|
261
|
-
'title': self.get_title(),
|
262
|
-
'view_type': 'form',
|
263
|
-
'form_id': self.form_id,
|
264
|
-
'querystring': build_querystring(self.get_params, ['page']),
|
265
|
-
'actions': []
|
266
|
-
}
|
267
|
-
if self.add_default_actions:
|
268
|
-
ctx.update({'actions': self.get_default_form_actions()})
|
269
|
-
ctx['actions'].extend(self.actions)
|
270
|
-
ctx.update(self.context)
|
271
|
-
return ctx
|
272
|
-
|
273
|
-
|
274
|
-
def build_querystring(get_params: dict, extra_params: list[str] = None) -> str:
|
275
|
-
querystring = f'?q={get_params.get("q", "[]")}'
|
276
|
-
if paginate_by := get_params.get('paginate_by', False):
|
277
|
-
querystring += f'&paginate_by={paginate_by}'
|
278
|
-
if order_by := get_params.get('order_by', False):
|
279
|
-
querystring += f'&order_by={order_by}'
|
280
|
-
for param in extra_params or []:
|
281
|
-
if value := get_params.get(param, False):
|
282
|
-
querystring += f'&{param}={value}'
|
283
|
-
return querystring
|
284
|
-
|
285
|
-
|
286
|
-
def queryset_from_querystring(
|
287
|
-
model: type[Model|Manager],
|
288
|
-
query_string: str,
|
289
|
-
order_by: str|list[str] = None,
|
290
|
-
) -> QuerySet:
|
291
|
-
"""
|
292
|
-
param url_query_string: json serializable string
|
293
|
-
[[{"name__iexact": "asdf"}, {"active": true}], [{"group__name__isnull": false}]]
|
294
|
-
"""
|
295
|
-
|
296
|
-
if not isinstance(model, Manager):
|
297
|
-
model = model.objects
|
298
|
-
|
299
|
-
query_data = json.loads(query_string)
|
300
|
-
query = Q()
|
301
|
-
|
302
|
-
for query_block in query_data:
|
303
|
-
block_query = Q()
|
304
|
-
for query_term in query_block:
|
305
|
-
if isinstance(query_term, dict):
|
306
|
-
for param, value in query_term.items():
|
307
|
-
block_query &= get_query(model.model, param, value)
|
308
|
-
elif isinstance(query_term, list):
|
309
|
-
inner_block_query = Q()
|
310
|
-
for inner_query_term in query_term:
|
311
|
-
for param, value in inner_query_term.items():
|
312
|
-
inner_block_query |= get_query(model.model, param, value)
|
313
|
-
block_query &= inner_block_query
|
314
|
-
query |= block_query
|
315
|
-
|
316
|
-
queryset = model.filter(query)
|
317
|
-
|
318
|
-
if order_by is None:
|
319
|
-
return queryset
|
320
|
-
|
321
|
-
try:
|
322
|
-
order = order_by.split(',')
|
323
|
-
except AttributeError:
|
324
|
-
order = order_by or []
|
325
|
-
|
326
|
-
for o in order_by:
|
327
|
-
desc = False
|
328
|
-
if o.startswith('-'):
|
329
|
-
o = o[1:]
|
330
|
-
desc = True
|
331
|
-
try:
|
332
|
-
model_field = model.model._meta.get_field(o)
|
333
|
-
except FieldDoesNotExist:
|
334
|
-
model_field = None
|
335
|
-
if o == 'pk':
|
336
|
-
pass
|
337
|
-
if isinstance(model_field, CharField):
|
338
|
-
if desc:
|
339
|
-
order.append(Lower(o).desc())
|
340
|
-
else:
|
341
|
-
order.append(Lower(o).asc())
|
342
|
-
else:
|
343
|
-
order.append(f'{"-" if desc else ""}{o}')
|
344
|
-
return queryset.order_by(*order)
|
345
|
-
|
346
|
-
|
347
|
-
def get_related_model(model, path):
|
348
|
-
related_model = model
|
349
|
-
for part in path:
|
350
|
-
try:
|
351
|
-
related_model = related_model._meta.fields_map[part].related_model
|
352
|
-
except (AttributeError, KeyError):
|
353
|
-
continue
|
354
|
-
return related_model
|
355
|
-
|
356
|
-
|
357
|
-
def get_query(model, param: str, value) -> Q:
|
358
|
-
invert = False
|
359
|
-
parts = param.split('__')
|
360
|
-
if param.startswith('~'):
|
361
|
-
param = param[1:]
|
362
|
-
invert = True
|
363
|
-
if len(parts) == 1:
|
364
|
-
parts.append('exact')
|
365
|
-
attribute = parts[-2]
|
366
|
-
|
367
|
-
if not attribute.startswith('_c_'):
|
368
|
-
query = Q(**{param: value})
|
369
|
-
return ~query if invert else query
|
370
|
-
|
371
|
-
operator = parts[-1]
|
372
|
-
related_model = get_related_model(model, parts[:-2])
|
373
|
-
func = getattr(related_model, attribute[3:])
|
374
|
-
|
375
|
-
obj_ids = [
|
376
|
-
obj.id for obj in
|
377
|
-
filter(
|
378
|
-
lambda instance:
|
379
|
-
evaluate(instance, func, value, operator),
|
380
|
-
related_model.objects.all()
|
381
|
-
)
|
382
|
-
]
|
383
|
-
|
384
|
-
query = Q(**{
|
385
|
-
f'{"__".join(parts[:-2])}{"__" if parts[:-2] else ""}id__in': obj_ids
|
386
|
-
})
|
387
|
-
return ~query if invert else query
|
388
|
-
|
389
|
-
|
390
|
-
def evaluate(instance, func, value, operator):
|
391
|
-
return_type = func.__annotations__.get('return', str)
|
392
|
-
try:
|
393
|
-
value = return_type(value)
|
394
|
-
except TypeError as e:
|
395
|
-
if isinstance(return_type, datetime.datetime):
|
396
|
-
value = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M')
|
397
|
-
elif isinstance(return_type, datetime.date):
|
398
|
-
value = datetime.datetime.strptime(value, '%Y-%m-%d')
|
399
|
-
else:
|
400
|
-
raise e
|
401
|
-
|
402
|
-
return_value = func(instance)
|
403
|
-
|
404
|
-
if operator == 'exact':
|
405
|
-
return value == return_value
|
406
|
-
elif operator == 'icontains':
|
407
|
-
return value.lower() in return_value.lower()
|
408
|
-
elif operator == 'contains':
|
409
|
-
return value in return_value
|
410
|
-
elif operator == 'gt':
|
411
|
-
return return_value > value
|
412
|
-
elif operator == 'gte':
|
413
|
-
return return_value >= value
|
414
|
-
elif operator == 'lte':
|
415
|
-
return return_value <= value
|
416
|
-
elif operator == 'lt':
|
417
|
-
return return_value < value
|
accrete-0.0.10.dist-info/RECORD
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
accrete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
accrete/admin.py,sha256=MUYUmCFlGYPowiXTbwl4_Q6Cq0-neiL53WW4P76JCLs,1174
|
3
|
-
accrete/apps.py,sha256=F7ynMLHJr_6bRujWtZVUzCliY2CGKiDvyUmL4F68L2E,146
|
4
|
-
accrete/config.py,sha256=eJUbvyBO3DvAD6xkVKjTAzlXy7V7EK9bVyb91girfUs,299
|
5
|
-
accrete/decorators.py,sha256=vM8GuDHLzwEpHmTGafG-xwMddKvuYFIhe-FrUJqL1_4,678
|
6
|
-
accrete/forms.py,sha256=hwUwlfM8v7gPFxH_foN1jIXzYH32GdX-FrPZgh0Qv1Q,11137
|
7
|
-
accrete/middleware.py,sha256=ldnMI4Wv9p1JUyFX_sQSa6Hg4MgkXNbKaHqq5aRsD8s,2629
|
8
|
-
accrete/models.py,sha256=_k8fOYFEOp3WN5rFHNCWDMMJ_H6HGSNiFHPsg2dv2Lg,5229
|
9
|
-
accrete/queries.py,sha256=j5VFl50Zma6CdyFWahkNeimUlDRzu8WkHB4rGWy0hhA,406
|
10
|
-
accrete/shortcuts.py,sha256=prs4aGWJ1dAeL4K6QLvP5dRHMsE7rDf0c6N_POCCqjo,237
|
11
|
-
accrete/tenant.py,sha256=c_5G8qqO0dHAVY3fiN6oDNKQ61APTpcGgZeHLb9Kb8c,1077
|
12
|
-
accrete/tests.py,sha256=Agltbzwwh5htvq_Qi9vqvxutzmg_GwgPS_N19xJZRlw,7197
|
13
|
-
accrete/views.py,sha256=6BERfW0JbB-dllSsDXRGOrcQrytok2JB5ax0RLZEers,2315
|
14
|
-
accrete/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
accrete/contrib/sequence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
accrete/contrib/sequence/admin.py,sha256=mTjab5cVklRUIQcSrsUo-_JgtXEsSdcFj_gfWhlStS4,273
|
17
|
-
accrete/contrib/sequence/apps.py,sha256=2SalOz9piCrbOPudCh0grN1eojN9kEC4-jcNzBmfqEk,164
|
18
|
-
accrete/contrib/sequence/forms.py,sha256=M3BCc3Wsbpymweny5caBe6pUENwjPgfMGdLBKWfwkYw,235
|
19
|
-
accrete/contrib/sequence/models.py,sha256=zXK0aCdsDiXQU_51UZBElL6DUvnMdKEAITxPX57NNEI,886
|
20
|
-
accrete/contrib/sequence/queries.py,sha256=ykSxbbYjI2n3pjZskNXBGTJk0ca7H0NFzFP-nZlVDQU,684
|
21
|
-
accrete/contrib/sequence/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
22
|
-
accrete/contrib/sequence/views.py,sha256=xc1IQHrsij7j33TUbo-_oewy3vs03pw_etpBWaMYJl0,63
|
23
|
-
accrete/contrib/sequence/migrations/0001_initial.py,sha256=iAR_hhGN2wDAk40IS9PwEsm7iYqfgasoKRrTLFEpOY8,1352
|
24
|
-
accrete/contrib/sequence/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
|
-
accrete/contrib/system_mail/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
-
accrete/contrib/system_mail/admin.py,sha256=9hXwwfZn446juyRoBOygLWm12X6N9waRC-1LHBLrgZk,227
|
27
|
-
accrete/contrib/system_mail/apps.py,sha256=yIWgsa5GV8NPOJBtDZQJljSZ5v_mOP6VJrTfo_HkLF8,169
|
28
|
-
accrete/contrib/system_mail/forms.py,sha256=baRoj0YQvc-b83y69dbxVgCN5BWoQsco_YRNqqbubY8,723
|
29
|
-
accrete/contrib/system_mail/models.py,sha256=mTx8YAtyyrUE2B8iKQDyJVsUqN1EGHg8XKgdoWibZ9g,880
|
30
|
-
accrete/contrib/system_mail/tasks.py,sha256=xfAX49wIxYuWDZBuPrWyQt3GPpukK0xMjHtUsgEsMkI,1089
|
31
|
-
accrete/contrib/system_mail/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
32
|
-
accrete/contrib/system_mail/views.py,sha256=xc1IQHrsij7j33TUbo-_oewy3vs03pw_etpBWaMYJl0,63
|
33
|
-
accrete/contrib/system_mail/migrations/0001_initial.py,sha256=6cwkkRXGjXvwXoMjjgmWmcPyXSTlUbhW1vMiHObk9MQ,1074
|
34
|
-
accrete/contrib/system_mail/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
|
-
accrete/contrib/ui/__init__.py,sha256=b0Aq41co9EVKRKKrsRyhHQsUHCqtbaeI90slAxSLgK0,207
|
36
|
-
accrete/contrib/ui/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,63
|
37
|
-
accrete/contrib/ui/apps.py,sha256=E0ao2ox6PQ3ldfeR17FXJUUJuGiWjm2DPCxHbPXGzls,152
|
38
|
-
accrete/contrib/ui/filter.py,sha256=xTziJ7ySfbpwtaWAusJSkNUtaZbEeX9UKES2AKIuAak,11897
|
39
|
-
accrete/contrib/ui/helper.py,sha256=lmHcBQ4L-jtVyBuR3NH4EJRYYuK511KmkbpGxHXXByA,13100
|
40
|
-
accrete/contrib/ui/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
41
|
-
accrete/contrib/ui/urls.py,sha256=TUBlz_CGs9InTZoxM78GSnucA73I8knoh_obt12RUHM,186
|
42
|
-
accrete/contrib/ui/views.py,sha256=WpBKMsxFFG8eG4IN7TW_TPE6i3OFF7gnLDTK7JMKti8,191
|
43
|
-
accrete/contrib/ui/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
-
accrete/contrib/ui/static/css/accrete.css,sha256=Yd0eoRRFp-BV7ha16bhvNuXlgdwcCBOij1HUBACUWew,2289
|
45
|
-
accrete/contrib/ui/static/css/icons.css,sha256=-a9BJHrH5P02cfL5qZLZHZkyupqigWmbc5wAa0UEDrE,3035
|
46
|
-
accrete/contrib/ui/static/icons/Logo.svg,sha256=hGZuxrAa-LRpFavFiF8Lnc7X9OQcqmb6Xl_dxx-27hM,1861
|
47
|
-
accrete/contrib/ui/static/icons/accrete.svg,sha256=CWHJKIgk3hxL7xIaFSz2j1cK-eF1TroCbjcF58bgOIs,1024
|
48
|
-
accrete/contrib/ui/static/js/filter.js,sha256=FleoqtZ6SanlF3cy4FYfN47OsVXBRmt_O4CnUOP96S8,19186
|
49
|
-
accrete/contrib/ui/static/js/list.js,sha256=OX_81ifRmawE-1QBU5Qpq_E6sHiiNwIPleETAn9EOJw,4280
|
50
|
-
accrete/contrib/ui/static/js/navbar.js,sha256=9QGZfPgGWjCBZhZhrRf983hoPnRlwQP-Pl73c2vISYs,628
|
51
|
-
accrete/contrib/ui/static/js/utils.js,sha256=6RKh3EJ57gx5UIjBcSaeZEs7lZdLvyYT9VAQ-WqlKSk,173
|
52
|
-
accrete/contrib/ui/templates/django/forms/widgets/attrs.html,sha256=zNxjU4Ta_eWZkh1WhrF_VIwNZ0lZyl980gSSijUK51k,195
|
53
|
-
accrete/contrib/ui/templates/django/forms/widgets/email.html,sha256=fXpbxMzAdbv_avfWC5464gD2jFng931Eq7vzbzy1-yA,48
|
54
|
-
accrete/contrib/ui/templates/django/forms/widgets/file.html,sha256=J1NmXmQTp6IU48K-zRdLeYl-1Tpavx6ZAo3cPIP9Y6Y,755
|
55
|
-
accrete/contrib/ui/templates/django/forms/widgets/input.html,sha256=CRu81kTsbPwis7NknCv6i7EQkOwexR9rURaRpoGHBek,248
|
56
|
-
accrete/contrib/ui/templates/django/forms/widgets/select.html,sha256=jT_UnHizHfdWTdJoSxjcIqTiR7NbVBA4bBSvkuDPRtw,394
|
57
|
-
accrete/contrib/ui/templates/django/forms/widgets/text.html,sha256=MSmLlQc7PsPoDLVtTOOiWNprrsPriNr712yFxaHyDIo,47
|
58
|
-
accrete/contrib/ui/templates/django/forms/widgets/textarea.html,sha256=c9BTedqb3IkXLyVYd0p9pR8DFnsXCNGoxVBWZTk_Fic,278
|
59
|
-
accrete/contrib/ui/templates/ui/detail.html,sha256=m-CpLcoK-dL5jPlIY6Hzyq2EyEqcFZ5Bn-kB-T0Oqao,510
|
60
|
-
accrete/contrib/ui/templates/ui/form.html,sha256=HpcZCDU_ur_Zf5gpnH_F8OV6qfOYPl6Ecqg6w5RIayQ,405
|
61
|
-
accrete/contrib/ui/templates/ui/layout.html,sha256=qvmJ4KTQM5Q_joxrxE_e4oDEqWkWJuB4T1iaYCLROl0,7059
|
62
|
-
accrete/contrib/ui/templates/ui/list.html,sha256=HsmJAWDZU-qCPh4mrc8vGzkULbViG5fnLcmmp-NO2-4,671
|
63
|
-
accrete/contrib/ui/templates/ui/table.html,sha256=8-Xao_A_4Avm8Hbu7ctFQNUCgMGd22aCFP-Xw8FDPBc,1446
|
64
|
-
accrete/contrib/ui/templates/ui/partials/filter.html,sha256=l_Vi3ZRepF5lpX_KENU4AyIELSeichsVr0g2KGHcjIQ,1844
|
65
|
-
accrete/contrib/ui/templates/ui/partials/form_errors.html,sha256=1_TQvTdiejsn-43YSyp2YfnP52P-MFYb-HGY0DLm4oA,991
|
66
|
-
accrete/contrib/ui/templates/ui/partials/form_modal.html,sha256=FFDfI5qjOCUBSGqDjBXa8tcqN2q94wOOCNFDaiyplHQ,1032
|
67
|
-
accrete/contrib/ui/templates/ui/partials/header.html,sha256=1ySXpc9TJk5wZXXqAEX5f_HmM0DbOQXaPJ8lfu265e0,3048
|
68
|
-
accrete/contrib/ui/templates/ui/partials/onchange_form.html,sha256=K5twTGqRUW1iM2dGtdWntjsJvJVo5EIzKxX2HK-H1yw,160
|
69
|
-
accrete/contrib/ui/templates/ui/partials/pagination_detail.html,sha256=9rQEaE31gU8sUFLireZ9iju78HucADBK1TQOb9nqw2I,1003
|
70
|
-
accrete/contrib/ui/templates/ui/partials/pagination_list.html,sha256=MkIRMnCCUnK7Ksoy4SqXdMtnpqgHeCv5GyMN3tzNfCc,1232
|
71
|
-
accrete/contrib/ui/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
72
|
-
accrete/contrib/ui/templatetags/accrete_ui.py,sha256=otBEHrMM4JuYtx9DuK52OE1YM5vwS8KGs8CGevGwBpE,2478
|
73
|
-
accrete/contrib/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
74
|
-
accrete/contrib/user/admin.py,sha256=YS4iApli7XUaIl9GsEJxys2j8sepX0by88omYHjff-E,85
|
75
|
-
accrete/contrib/user/apps.py,sha256=oHDrAiHf-G57mZLyxqGJzRY2DbPprGFD-QgyVJG_ruI,156
|
76
|
-
accrete/contrib/user/middleware.py,sha256=qblcujwJsthopagyT-hPFq4HsMyGt-VvqZw5TQopBjk,403
|
77
|
-
accrete/contrib/user/models.py,sha256=8BSuqY55f99yBBcXWqHHKvJYKVZxF95oGAdYMQOoco4,3431
|
78
|
-
accrete/contrib/user/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
79
|
-
accrete/contrib/user/urls.py,sha256=M5O0gZgOw8npi6inEt3R1YA8PWkHL9o79fegj8GrNZA,212
|
80
|
-
accrete/contrib/user/views.py,sha256=qX7g5Xg8_ZXugbH7fZup0jJGLjBQwBa_ARpmgeDefDA,844
|
81
|
-
accrete/contrib/user/locale/de/LC_MESSAGES/django.mo,sha256=p3rgUg6WltAVIMkQsjvjBqTsd_usLhSr1GH4Cyltc2c,433
|
82
|
-
accrete/contrib/user/locale/de/LC_MESSAGES/django.po,sha256=f_Nxpo3HTm2L3f3zoHLfeWsZ-4IQp_EEVSku6TCZSvw,1870
|
83
|
-
accrete/contrib/user/migrations/0001_initial.py,sha256=JWfM9PcMDfkJUdCjLWuWieGs6643qP0KdbCyr5uAZoY,2950
|
84
|
-
accrete/contrib/user/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
85
|
-
accrete/contrib/user/templates/user/login.html,sha256=qKUqF5WCkWPrbwQMaa05Ou7zkM_CeVrJzHsjsDWNPhQ,1644
|
86
|
-
accrete/contrib/user_registration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
87
|
-
accrete/contrib/user_registration/admin.py,sha256=kwmGTsg4Hii-lsw9-UaJG7AhQ4k4SPi48GSrtpZ4YR4,119
|
88
|
-
accrete/contrib/user_registration/apps.py,sha256=mYu3fuuubfjImeJHk4D_Wd6Edw2r3oUNXGcFbAkhir4,181
|
89
|
-
accrete/contrib/user_registration/config.py,sha256=wrZuZY5ed9dCFKp5W2iRUAoHN9xAoetEU8BuuKSofRg,949
|
90
|
-
accrete/contrib/user_registration/forms.py,sha256=rTDcpVlGPDyfTRIQquJr4hNshmJEOplYDwOT782xLys,3281
|
91
|
-
accrete/contrib/user_registration/models.py,sha256=bxDQ_UTeLMmU6tjNfwVLenWuJu_WNZEm3-uPNeOAidk,398
|
92
|
-
accrete/contrib/user_registration/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
93
|
-
accrete/contrib/user_registration/urls.py,sha256=lC1uHBHY3lgJVooZaMx7quTnqDsG01JQq_XRXQVjz3o,382
|
94
|
-
accrete/contrib/user_registration/views.py,sha256=sUW2QttAFjJvqZVsTrvGpZQ0qVham61zdVok9n-6pHU,3060
|
95
|
-
accrete/contrib/user_registration/migrations/0001_initial.py,sha256=XKflQ2gPgKjW28LgP_nDX6vgClxuZLJ6xWVppbEgX8M,896
|
96
|
-
accrete/contrib/user_registration/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
97
|
-
accrete/contrib/user_registration/templates/user_registration/registration.html,sha256=E3jcS4WwlEowzGrnIQ35B-tTrkEILBbqQrxDx2f6lys,2079
|
98
|
-
accrete/contrib/user_registration/templates/user_registration/mail_templates/confirmation_mail.html,sha256=5UkpGUrDAazrr_gKguOnOykr77a2FLgD2gnvUxzHfyg,192
|
99
|
-
accrete/migrations/0001_initial.py,sha256=azThbc8otEhxJwo8BIgOt5eC30mxXhKJLBAazZFe3BA,4166
|
100
|
-
accrete/migrations/0002_initial.py,sha256=dFOM7kdHlx7pVAh8cTDlZMtciN4O9Z547HAzEKnygZE,1628
|
101
|
-
accrete/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
102
|
-
accrete/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
103
|
-
accrete/utils/dates.py,sha256=XI58CqabLCC-Sg6qo5TPWh-pHuuZfDdGDU6KQeAMlGo,1066
|
104
|
-
accrete-0.0.10.dist-info/METADATA,sha256=BrF6ss_yzTfcZAJ8YNSwt9K3ims6g5fsbCtNx4cRJ9o,4846
|
105
|
-
accrete-0.0.10.dist-info/WHEEL,sha256=9QBuHhg6FNW7lppboF2vKVbCGTVzsFykgRQjjlajrhA,87
|
106
|
-
accrete-0.0.10.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
|
107
|
-
accrete-0.0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|