diff --git a/apps/settings/models.py b/apps/settings/models.py index b39408098..98964ad0e 100644 --- a/apps/settings/models.py +++ b/apps/settings/models.py @@ -7,6 +7,7 @@ from django.core.files.uploadedfile import InMemoryUploadedFile from django.db import models from django.db.utils import ProgrammingError, OperationalError from django.utils.translation import gettext_lazy as _ +from rest_framework.utils.encoders import JSONEncoder from common.db.models import JMSBaseModel from common.utils import signer, get_logger @@ -63,7 +64,7 @@ class Setting(models.Model): @cleaned_value.setter def cleaned_value(self, item): try: - v = json.dumps(item) + v = json.dumps(item, cls=JSONEncoder) if self.encrypted: v = signer.sign(v) self.value = v diff --git a/apps/settings/serializers/feature.py b/apps/settings/serializers/feature.py index 4b219373d..3deb49942 100644 --- a/apps/settings/serializers/feature.py +++ b/apps/settings/serializers/feature.py @@ -1,10 +1,11 @@ import uuid - +from django.utils import timezone from django.utils.translation import gettext_lazy as _ from rest_framework import serializers from assets.const import Protocol from common.serializers.fields import EncryptedField +from common.utils import date_expired_default __all__ = [ 'AnnouncementSettingSerializer', 'OpsSettingSerializer', @@ -21,6 +22,8 @@ class AnnouncementSerializer(serializers.Serializer): required=False, allow_null=True, allow_blank=True, label=_("More Link"), default='', ) + DATE_START = serializers.DateTimeField(default=timezone.now, label=_("Date start")) + DATE_END = serializers.DateTimeField(default=date_expired_default, label=_("Date end")) def to_representation(self, instance): defaults = {'ID': '', 'SUBJECT': '', 'CONTENT': '', 'LINK': '', 'ENABLED': False}