Browse Source

feat: Add announcement start and end dates

pull/14095/head
wangruidong 3 months ago committed by Bryan
parent
commit
50d3a4906a
  1. 3
      apps/settings/models.py
  2. 5
      apps/settings/serializers/feature.py

3
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

5
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}

Loading…
Cancel
Save