mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-01 10:02:01 +00:00
33 lines
910 B
Python
33 lines
910 B
Python
from account.models import User
|
|
from utils.api import serializers
|
|
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()
|
|
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)
|
|
visible = serializers.BooleanField()
|