2017-01-23 16:48:04 +08:00
|
|
|
from utils.api import serializers
|
2017-12-01 17:19:31 +08:00
|
|
|
from utils.api._serializers import UsernameSerializer
|
2017-01-23 16:48:04 +08:00
|
|
|
|
2015-08-06 16:28:59 +08:00
|
|
|
from .models import Announcement
|
2015-08-04 17:38:04 +08:00
|
|
|
|
2015-08-06 16:28:59 +08:00
|
|
|
|
|
|
|
class CreateAnnouncementSerializer(serializers.Serializer):
|
2017-10-02 05:16:14 +08:00
|
|
|
title = serializers.CharField(max_length=64)
|
|
|
|
content = serializers.CharField(max_length=1024 * 1024 * 8)
|
2017-01-25 09:36:33 +08:00
|
|
|
visible = serializers.BooleanField()
|
2015-08-04 17:38:04 +08:00
|
|
|
|
2015-08-06 16:28:59 +08:00
|
|
|
|
|
|
|
class AnnouncementSerializer(serializers.ModelSerializer):
|
2017-01-26 12:33:00 +08:00
|
|
|
created_by = UsernameSerializer()
|
2015-08-06 16:28:59 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Announcement
|
2017-12-01 17:19:31 +08:00
|
|
|
fields = "__all__"
|
2015-08-06 16:28:59 +08:00
|
|
|
|
2015-08-06 19:07:46 +08:00
|
|
|
|
|
|
|
class EditAnnouncementSerializer(serializers.Serializer):
|
|
|
|
id = serializers.IntegerField()
|
2017-10-02 05:16:14 +08:00
|
|
|
title = serializers.CharField(max_length=64)
|
|
|
|
content = serializers.CharField(max_length=1024 * 1024 * 8)
|
2016-09-25 14:07:45 +08:00
|
|
|
visible = serializers.BooleanField()
|