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
|
|
|
|
2015-08-06 08:28:59 +00:00
|
|
|
from .models import Announcement
|
2015-08-04 09:38:04 +00:00
|
|
|
|
2015-08-06 08:28:59 +00:00
|
|
|
|
|
|
|
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)
|
2017-01-25 01:36:33 +00:00
|
|
|
visible = serializers.BooleanField()
|
2015-08-04 09:38:04 +00:00
|
|
|
|
2015-08-06 08:28:59 +00:00
|
|
|
|
|
|
|
class AnnouncementSerializer(serializers.ModelSerializer):
|
2016-08-01 14:22:26 +00:00
|
|
|
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()
|
2015-08-06 08:28:59 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Announcement
|
|
|
|
|
2015-08-06 11:07:46 +00:00
|
|
|
|
|
|
|
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()
|