OnlineJudge/announcement/serializers.py

33 lines
910 B
Python
Raw Normal View History

2016-11-19 04:32:23 +00:00
from utils.api import serializers
from account.models import User
2016-11-19 04:32:23 +00:00
from utils.api._serializers import DateTimeTZField
from .models import Announcement
class CreateAnnouncementSerializer(serializers.Serializer):
title = serializers.CharField(max_length=50)
content = serializers.CharField(max_length=10000)
class AnnouncementSerializer(serializers.ModelSerializer):
create_time = DateTimeTZField()
2016-08-02 11:56:59 +00:00
last_update_time = DateTimeTZField()
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ["username"]
created_by = UserSerializer()
class Meta:
model = Announcement
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()