OnlineJudge/announcement/serializers.py

27 lines
827 B
Python
Raw Normal View History

2017-01-23 08:48:04 +00:00
from utils.api import serializers
2017-01-26 04:33:00 +00:00
from utils.api._serializers import DateTimeTZField, UsernameSerializer
2017-01-23 08:48:04 +00:00
from .models import Announcement
class CreateAnnouncementSerializer(serializers.Serializer):
2017-10-01 21:16:14 +00:00
title = serializers.CharField(max_length=64)
content = serializers.CharField(max_length=1024 * 1024 * 8)
visible = serializers.BooleanField()
class AnnouncementSerializer(serializers.ModelSerializer):
create_time = DateTimeTZField()
2016-08-02 11:56:59 +00:00
last_update_time = DateTimeTZField()
2017-01-26 04:33:00 +00:00
created_by = UsernameSerializer()
class Meta:
model = Announcement
class EditAnnouncementSerializer(serializers.Serializer):
id = serializers.IntegerField()
2017-10-01 21:16:14 +00:00
title = serializers.CharField(max_length=64)
content = serializers.CharField(max_length=1024 * 1024 * 8)
2016-09-25 06:07:45 +00:00
visible = serializers.BooleanField()