# Path: apps/core/models.py
# class Notice(models.Model):
#     """
#     denotes single notice
#     - title:      notice title
#     - valid_from: display start time
#     - valid_to:   display end time
#     - text:       notice content; html
#     """
#     title = models.CharField(max_length=100)
#     valid_from = models.DateTimeField()
#     valid_to = models.DateTimeField()
#     text = models.TextField()
# 
#     def to_dict(self):
#         return {
#             'valid_from': self.valid_from.isoformat(),
#             'valid_to': self.valid_to.isoformat(),
#             'title': self.title,
#             'text': self.text,
#         }
# 
#     def __str__(self):
#         return self.title


from rest_framework import fields, serializers
from apps.core.models import Notice



class NoticeFilterSerializer(serializers.Serializer):
    offset = fields.IntegerField(required=False, default=0, min_value=0)
    limit = fields.IntegerField(required=False, default=3, min_value=0, max_value=10)
    date_after = fields.IntegerField(required=False, default=0, min_value=0)


class NoticeSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notice
        fields = ['valid_from', 'valid_to', 'title', 'text']


class TokenInfoQuerySerializer(serializers.Serializer):
    client_id = serializers.CharField(required=True)
    timestamp = serializers.CharField(required=True)

# Path: apps/core/models.py
# class Notice(models.Model):
#     """
#     denotes single notice
#     - title:      notice title
#     - valid_from: display start time
#     - valid_to:   display end time
#     - text:       notice content; html
#     """
#     title = models.CharField(max_length=100)
#     valid_from = models.DateTimeField()
#     valid_to = models.DateTimeField()
#     text = models.TextField()
# 
#     def to_dict(self):
#         return {
#             'valid_from': self.valid_from.isoformat(),
#             'valid_to': self.valid_to.isoformat(),
#             'title': self.title,
#             'text': self.text,
#         }
# 
#     def __str__(self):
#         return self.title


# Path: apps/api/serializers.py
from rest_framework import fields, serializers
from apps.core.models import Notice




class NoticeFilterSerializer(serializers.Serializer):
    offset = fields.IntegerField(required=False, default=0, min_value=0)
    limit = fields.IntegerField(required=False, default=3, min_value=0, max_value=10)
    date_after = fields.IntegerField(required=False, default=0, min_value=0)


class NoticeSerializer(serializers.ModelSerializer):
    class Meta:
        model = Notice
        fields = ['valid_from', 'valid_to', 'title', 'text']


class TokenInfoQuerySerializer(serializers.Serializer):
    client_id = serializers.CharField(required=True)
    timestamp = serializers.CharField(required=True)

    sign = serializers.CharField(required=True)