diff --git a/apps/assets/templates/assets/_system_user.html b/apps/assets/templates/assets/_system_user.html index 99b64af30..07299ea08 100644 --- a/apps/assets/templates/assets/_system_user.html +++ b/apps/assets/templates/assets/_system_user.html @@ -90,7 +90,7 @@ } } $(document).ready(function () { - $('.select2').select2(); + $('.select2').select2({ dropdownAutoWidth : true, width: 'auto' }); authFieldsDisplay(); $(auto_generate_key).change(function () { authFieldsDisplay(); diff --git a/apps/assets/templates/assets/admin_user_create_update.html b/apps/assets/templates/assets/admin_user_create_update.html index d7d5094ff..30ef3e93a 100644 --- a/apps/assets/templates/assets/admin_user_create_update.html +++ b/apps/assets/templates/assets/admin_user_create_update.html @@ -56,7 +56,7 @@ {% block custom_foot_js %} {% endblock %} \ No newline at end of file diff --git a/apps/assets/templates/assets/admin_user_detail.html b/apps/assets/templates/assets/admin_user_detail.html index b5eb5da05..2614efda2 100644 --- a/apps/assets/templates/assets/admin_user_detail.html +++ b/apps/assets/templates/assets/admin_user_detail.html @@ -157,7 +157,7 @@ function bindToCluster(clusters) { jumpserver.cluster_selected = {}; $(document).ready(function () { - $('.select2').select2().on('select2:select', function(evt) { + $('.select2').select2({ dropdownAutoWidth : true, width: 'auto' });.on('select2:select', function(evt) { var data = evt.params.data; jumpserver.cluster_selected[data.id] = data.text; }).on('select2:unselect', function(evt) { diff --git a/apps/assets/templates/assets/asset_bulk_update.html b/apps/assets/templates/assets/asset_bulk_update.html index e72b44302..cc33d7faf 100644 --- a/apps/assets/templates/assets/asset_bulk_update.html +++ b/apps/assets/templates/assets/asset_bulk_update.html @@ -30,7 +30,7 @@ {% block custom_foot_js %} {% endblock %} \ No newline at end of file diff --git a/apps/assets/templates/assets/cluster_detail.html b/apps/assets/templates/assets/cluster_detail.html index cd2ecd25e..ae57df263 100644 --- a/apps/assets/templates/assets/cluster_detail.html +++ b/apps/assets/templates/assets/cluster_detail.html @@ -151,7 +151,7 @@ {% endblock %} \ No newline at end of file diff --git a/apps/common/mixins.py b/apps/common/mixins.py index 8f6076e4a..534a9a013 100644 --- a/apps/common/mixins.py +++ b/apps/common/mixins.py @@ -3,14 +3,14 @@ import inspect from django.db import models from django.http import JsonResponse -from django.utils.timezone import now +from django.utils import timezone from django.utils.translation import ugettext_lazy as _ class NoDeleteQuerySet(models.query.QuerySet): def delete(self): - return self.update(is_discard=True, discard_time=now()) + return self.update(is_discard=True, discard_time=timezone.now()) class NoDeleteManager(models.Manager): @@ -36,7 +36,7 @@ class NoDeleteModelMixin(models.Model): def delete(self): self.is_discard = True - self.discard_time = now() + self.discard_time = timezone.now() return self.save() @@ -87,3 +87,29 @@ class BulkSerializerMixin(object): return ret + +class DatetimeSearchMixin: + date_from = date_to = None + + def get(self, request, *args, **kwargs): + date_from_s = self.request.GET.get('date_from') + date_to_s = self.request.GET.get('date_to') + + if date_from_s: + date_from = timezone.datetime.strptime(date_from_s, '%m/%d/%Y') + self.date_from = date_from.replace( + tzinfo=timezone.get_current_timezone() + ) + else: + self.date_from = timezone.now() - timezone.timedelta(7) + + if date_to_s: + date_to = timezone.datetime.strptime( + date_to_s + ' 23:59:59', '%m/%d/%Y %H:%M:%S' + ) + self.date_to = date_to.replace( + tzinfo=timezone.get_current_timezone() + ) + else: + self.date_to = timezone.now() + return super().get(request, *args, **kwargs) \ No newline at end of file diff --git a/apps/ops/templates/ops/task_list.html b/apps/ops/templates/ops/task_list.html index 161a48ace..b2963e3b1 100644 --- a/apps/ops/templates/ops/task_list.html +++ b/apps/ops/templates/ops/task_list.html @@ -16,9 +16,9 @@