django-smartbase-admin 0.2.88__py3-none-any.whl → 0.2.90__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_smartbase_admin/admin/admin_base.py +0 -1
- django_smartbase_admin/engine/admin_base_view.py +1 -0
- django_smartbase_admin/engine/filter_widgets.py +34 -15
- django_smartbase_admin/static/sb_admin/dist/chart.js +1 -1
- django_smartbase_admin/static/sb_admin/dist/main.js +1 -1
- django_smartbase_admin/static/sb_admin/dist/main_style.css +1 -1
- django_smartbase_admin/static/sb_admin/dist/table.js +1 -1
- django_smartbase_admin/static/sb_admin/src/css/_datepicker.css +3 -0
- django_smartbase_admin/static/sb_admin/src/css/components/_query-builder.css +2 -1
- django_smartbase_admin/static/sb_admin/src/js/datepicker.js +71 -9
- django_smartbase_admin/static/sb_admin/src/js/datepicker_plugins.js +77 -42
- django_smartbase_admin/static/sb_admin/src/js/table_modules/advanced_filter_module.js +16 -9
- django_smartbase_admin/static/sb_admin/src/js/utils.js +5 -0
- django_smartbase_admin/templates/sb_admin/filter_widgets/advanced_filters/date_field.html +9 -2
- django_smartbase_admin/templates/sb_admin/filter_widgets/date_field.html +15 -5
- django_smartbase_admin/templates/sb_admin/includes/inline_fieldset.html +1 -1
- {django_smartbase_admin-0.2.88.dist-info → django_smartbase_admin-0.2.90.dist-info}/METADATA +1 -1
- {django_smartbase_admin-0.2.88.dist-info → django_smartbase_admin-0.2.90.dist-info}/RECORD +20 -20
- {django_smartbase_admin-0.2.88.dist-info → django_smartbase_admin-0.2.90.dist-info}/LICENSE.md +0 -0
- {django_smartbase_admin-0.2.88.dist-info → django_smartbase_admin-0.2.90.dist-info}/WHEEL +0 -0
|
@@ -652,7 +652,6 @@ class SBAdmin(
|
|
|
652
652
|
):
|
|
653
653
|
change_list_template = "sb_admin/actions/list.html"
|
|
654
654
|
change_form_template = "sb_admin/actions/change_form.html"
|
|
655
|
-
delete_confirmation_template = "sb_admin/actions/delete_confirmation.html"
|
|
656
655
|
delete_selected_confirmation_template = (
|
|
657
656
|
"sb_admin/actions/delete_selected_confirmation.html"
|
|
658
657
|
)
|
|
@@ -49,6 +49,7 @@ class SBAdminBaseView(object):
|
|
|
49
49
|
global_filter_data_map = None
|
|
50
50
|
field_cache = None
|
|
51
51
|
sbadmin_detail_actions = None
|
|
52
|
+
delete_confirmation_template = "sb_admin/actions/delete_confirmation.html"
|
|
52
53
|
|
|
53
54
|
def init_view_static(self, configuration, model, admin_site):
|
|
54
55
|
pass
|
|
@@ -308,13 +308,7 @@ class DateFilterWidget(SBAdminFilterWidget):
|
|
|
308
308
|
return DATE_ATTRIBUTES
|
|
309
309
|
|
|
310
310
|
def process_shortcut(self, shortcut, now):
|
|
311
|
-
return
|
|
312
|
-
"label": shortcut["label"],
|
|
313
|
-
"value": [
|
|
314
|
-
now + timedelta(days=shortcut["value"][0]),
|
|
315
|
-
now + timedelta(days=shortcut["value"][1]),
|
|
316
|
-
],
|
|
317
|
-
}
|
|
311
|
+
return shortcut
|
|
318
312
|
|
|
319
313
|
def get_shortcuts(self):
|
|
320
314
|
now = timezone.now()
|
|
@@ -332,12 +326,19 @@ class DateFilterWidget(SBAdminFilterWidget):
|
|
|
332
326
|
shortcuts[key].append(self.process_shortcut(shortcut, now))
|
|
333
327
|
return shortcuts
|
|
334
328
|
|
|
329
|
+
def get_default_label(self):
|
|
330
|
+
if self.default_value_shortcut_index is not None:
|
|
331
|
+
return self.get_shortcuts()[self.default_value_shortcut_index]["label"]
|
|
332
|
+
return super().get_default_value()
|
|
333
|
+
|
|
335
334
|
def get_default_value(self):
|
|
336
335
|
if self.default_value_shortcut_index is not None:
|
|
337
336
|
selected_shortcut_value = self.get_shortcuts()[
|
|
338
337
|
self.default_value_shortcut_index
|
|
339
338
|
]["value"]
|
|
340
|
-
return
|
|
339
|
+
return SBAdminViewService.json_dumps_for_url(
|
|
340
|
+
self.get_value_from_date_or_range(selected_shortcut_value)
|
|
341
|
+
)
|
|
341
342
|
return super().get_default_value()
|
|
342
343
|
|
|
343
344
|
def get_data(self):
|
|
@@ -379,12 +380,28 @@ class DateFilterWidget(SBAdminFilterWidget):
|
|
|
379
380
|
if filter_value is None:
|
|
380
381
|
return [None, None]
|
|
381
382
|
date_format = cls.DATE_FORMAT
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
383
|
+
if type(filter_value) is list:
|
|
384
|
+
if type(filter_value[0]) is int:
|
|
385
|
+
return [
|
|
386
|
+
timezone.now() + timedelta(days=filter_value[0]),
|
|
387
|
+
timezone.now() + timedelta(days=filter_value[1]),
|
|
388
|
+
]
|
|
389
|
+
return [
|
|
390
|
+
datetime.strptime(filter_value[0], date_format),
|
|
391
|
+
datetime.strptime(filter_value[1], date_format),
|
|
392
|
+
]
|
|
393
|
+
try:
|
|
394
|
+
days_range = json.loads(filter_value)
|
|
395
|
+
return [
|
|
396
|
+
timezone.now() + timedelta(days=days_range[0]),
|
|
397
|
+
timezone.now() + timedelta(days=days_range[1]),
|
|
398
|
+
]
|
|
399
|
+
except json.decoder.JSONDecodeError:
|
|
400
|
+
date_range = filter_value.split(cls.DATE_RANGE_SPLIT)
|
|
401
|
+
if len(date_range) == 2:
|
|
402
|
+
date_from = datetime.strptime(date_range[0], date_format)
|
|
403
|
+
date_to = datetime.strptime(date_range[1], date_format)
|
|
404
|
+
return [date_from, date_to]
|
|
388
405
|
date_value = datetime.strptime(filter_value, date_format)
|
|
389
406
|
return [date_value, date_value]
|
|
390
407
|
|
|
@@ -392,9 +409,11 @@ class DateFilterWidget(SBAdminFilterWidget):
|
|
|
392
409
|
def get_value_from_date_or_range(cls, date_or_range):
|
|
393
410
|
if not isinstance(date_or_range, list):
|
|
394
411
|
return datetime.strftime(date_or_range, cls.DATE_FORMAT)
|
|
412
|
+
if type(date_or_range[0]) is int:
|
|
413
|
+
return date_or_range
|
|
395
414
|
date_from = datetime.strftime(date_or_range[0], cls.DATE_FORMAT)
|
|
396
415
|
date_to = datetime.strftime(date_or_range[1], cls.DATE_FORMAT)
|
|
397
|
-
return
|
|
416
|
+
return [date_from, date_to]
|
|
398
417
|
|
|
399
418
|
def parse_value_from_input(self, request, filter_value):
|
|
400
419
|
return self.get_range_from_value(filter_value)
|