mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 00:22:03 +00:00
fix
This commit is contained in:
parent
675557668c
commit
796f748d10
@ -31,12 +31,17 @@ class DeleteGroupSerializer(serializers.Serializer):
|
||||
|
||||
class SimpleGroupSerializer(serializers.ModelSerializer):
|
||||
created_by = UsernameSerializer()
|
||||
password = serializers.SerializerMethodField()
|
||||
me = serializers.BooleanField()
|
||||
|
||||
def get_password(self, obj):
|
||||
return obj.password != ""
|
||||
|
||||
class Meta:
|
||||
model = Group
|
||||
fields = ["id", "created_by", "name"]
|
||||
fields = ["id", "created_by", "name", "password", "me"]
|
||||
|
||||
|
||||
class JoinGroupSerializer(serializers.Serializer):
|
||||
group_name = serializers.CharField()
|
||||
password = serializers.CharField()
|
||||
password = serializers.CharField(allow_blank=True)
|
@ -5,7 +5,10 @@ from ..serializers import SimpleGroupSerializer, JoinGroupSerializer
|
||||
|
||||
class GroupAPI(APIView):
|
||||
def get(self, request):
|
||||
return self.success(SimpleGroupSerializer(Group.objects.filter(allow_join=True).order_by("-id"), many=True).data)
|
||||
groups = Group.objects.filter(allow_join=True).order_by("-id")
|
||||
for item in groups:
|
||||
item.me = item.members.filter(username=request.user.username).exists()
|
||||
return self.success(SimpleGroupSerializer(groups, many=True).data)
|
||||
|
||||
@validate_serializer(JoinGroupSerializer)
|
||||
def post(self, request):
|
||||
|
@ -180,7 +180,7 @@ REST_FRAMEWORK = {
|
||||
)
|
||||
}
|
||||
|
||||
REDIS_URL = "redis://:foobar@%s:%s" % (REDIS_CONF["host"], REDIS_CONF["port"])
|
||||
REDIS_URL = "redis://@%s:%s" % (REDIS_CONF["host"], REDIS_CONF["port"])
|
||||
|
||||
|
||||
def redis_config(db):
|
||||
|
Loading…
Reference in New Issue
Block a user