Skip to content

Commit

Permalink
fix team update/create bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
acrantel committed Aug 23, 2023
1 parent fafb9b1 commit 79992f4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions backend/siarnaq/api/teams/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Meta:
"auto_accept_unranked",
"eligible_for",
]
read_only_fields = ["rating", "has_avatar", "avatar_url"]
read_only_fields = ["rating", "has_avatar", "avatar_url", "has_report"]

def create(self, validated_data):
eligible_for = validated_data.pop("eligible_for", None)
Expand Down Expand Up @@ -114,19 +114,15 @@ def __call__(self, serializer_field):

class TeamPrivateSerializer(TeamPublicSerializer):
profile = TeamProfilePrivateSerializer(required=False)
episode = serializers.PrimaryKeyRelatedField(
default=CurrentEpisodeDefault(), queryset=Episode.objects.all()
)

class Meta:
model = Team
fields = ["id", "profile", "episode", "name", "members", "join_key", "status"]
read_only_fields = ["id", "name", "members", "join_key", "status"]
read_only_fields = ["id", "episode", "name", "members", "join_key", "status"]

@transaction.atomic
def create(self, validated_data):
team = Team.objects.create(**validated_data)

# Add self to team
request = self.context.get("request")
team.members.add(request.user)
Expand All @@ -142,6 +138,10 @@ def update(self, instance, validated_data):


class TeamCreateSerializer(TeamPrivateSerializer):
episode = serializers.PrimaryKeyRelatedField(
default=CurrentEpisodeDefault(), queryset=Episode.objects.all()
)

class Meta:
model = Team
fields = ["id", "profile", "episode", "name", "members", "join_key", "status"]
Expand Down

0 comments on commit 79992f4

Please sign in to comment.