mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-16 01:13:47 +00:00
allow visible field when create announcement
This commit is contained in:
parent
1fc19eba21
commit
89859d9844
@ -8,6 +8,7 @@ from .models import Announcement
|
||||
class CreateAnnouncementSerializer(serializers.Serializer):
|
||||
title = serializers.CharField(max_length=50)
|
||||
content = serializers.CharField(max_length=10000)
|
||||
visible = serializers.BooleanField()
|
||||
|
||||
|
||||
class AnnouncementSerializer(serializers.ModelSerializer):
|
||||
|
@ -13,7 +13,7 @@ class AnnouncementAdminTest(APITestCase):
|
||||
self.assertSuccess(response)
|
||||
|
||||
def create_announcement(self):
|
||||
return self.client.post(self.url, data={"title": "test", "content": "test"})
|
||||
return self.client.post(self.url, data={"title": "test", "content": "test", "visible": True})
|
||||
|
||||
def test_create_announcement(self):
|
||||
resp = self.create_announcement()
|
||||
|
@ -18,7 +18,8 @@ class AnnouncementAdminAPI(APIView):
|
||||
data = request.data
|
||||
announcement = Announcement.objects.create(title=data["title"],
|
||||
content=data["content"],
|
||||
created_by=request.user)
|
||||
created_by=request.user,
|
||||
visible=data["visible"])
|
||||
return self.success(AnnouncementSerializer(announcement).data)
|
||||
|
||||
@validate_serializer(EditAnnouncementSerializer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user