2016-11-19 04:32:23 +00:00
|
|
|
from utils.api import serializers
|
2015-08-04 09:38:04 +00:00
|
|
|
|
2015-08-06 08:28:59 +00:00
|
|
|
from account.models import User
|
2016-11-19 04:32:23 +00:00
|
|
|
from utils.api._serializers import DateTimeTZField
|
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):
|
2015-08-04 09:38:04 +00:00
|
|
|
title = serializers.CharField(max_length=50)
|
2015-08-06 03:08:02 +00:00
|
|
|
content = serializers.CharField(max_length=10000)
|
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()
|
2015-08-06 08:28:59 +00:00
|
|
|
|
|
|
|
class UserSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ["username"]
|
|
|
|
|
|
|
|
created_by = UserSerializer()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Announcement
|
|
|
|
|
2015-08-06 11:07:46 +00:00
|
|
|
|
|
|
|
class EditAnnouncementSerializer(serializers.Serializer):
|
|
|
|
id = serializers.IntegerField()
|
|
|
|
title = serializers.CharField(max_length=50)
|
|
|
|
content = serializers.CharField(max_length=10000)
|
2016-09-25 06:07:45 +00:00
|
|
|
visible = serializers.BooleanField()
|