OnlineJudge/announcement/serializers.py

26 lines
760 B
Python
Raw Normal View History

2017-01-23 08:48:04 +00:00
from utils.api import serializers
2017-12-01 09:19:31 +00:00
from utils.api._serializers import 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):
2017-01-26 04:33:00 +00:00
created_by = UsernameSerializer()
class Meta:
model = Announcement
2017-12-01 09:19:31 +00:00
fields = "__all__"
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()