Skip to content

Commit

Permalink
API: Fix saving venue constraints
Browse files Browse the repository at this point in the history
As venue constraints use a generic FK, it needs to use the "Generic
Relation" field, rather than named for the model type.
  • Loading branch information
tienne-B committed Aug 27, 2024
1 parent f5876ff commit 8948791
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tabbycat/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def create(self, validated_data):
if len(venue_constraints) > 0:
vc = VenueConstraintSerializer(many=True, context=self.context)
vc._validated_data = venue_constraints # Data was already validated
vc.save(adjudicator=adj)
vc.save(subject=adj)

if url_key is None: # If explicitly null (and not just an empty string)
populate_url_keys([adj])
Expand All @@ -638,7 +638,7 @@ def update(self, instance, validated_data):
if len(venue_constraints) > 0:
vc = VenueConstraintSerializer(many=True, context=self.context)
vc._validated_data = venue_constraints # Data was already validated
vc.save(adjudicator=instance)
vc.save(subject=instance)

if 'base_score' in validated_data and validated_data['base_score'] != instance.base_score:
AdjudicatorBaseScoreHistory.objects.create(
Expand Down Expand Up @@ -771,7 +771,7 @@ def create(self, validated_data):
if len(venue_constraints) > 0:
vc = VenueConstraintSerializer(many=True, context=self.context)
vc._validated_data = venue_constraints # Data was already validated
vc.save(team=team)
vc.save(subject=team)

if team.institution is not None:
team.teaminstitutionconflict_set.get_or_create(institution=team.institution)
Expand All @@ -788,7 +788,7 @@ def update(self, instance, validated_data):
if len(venue_constraints) > 0:
vc = VenueConstraintSerializer(many=True, context=self.context)
vc._validated_data = venue_constraints # Data was already validated
vc.save(institution=instance)
vc.save(subject=instance)

if self.partial:
# Avoid removing conflicts if merely PATCHing
Expand Down Expand Up @@ -822,7 +822,7 @@ def create(self, validated_data):
if len(venue_constraints) > 0:
vc = VenueConstraintSerializer(many=True, context=self.context)
vc._validated_data = venue_constraints # Data was already validated
vc.save(institution=institution)
vc.save(subject=institution)

return institution

Expand All @@ -831,7 +831,7 @@ def update(self, instance, validated_data):
if len(venue_constraints) > 0:
vc = VenueConstraintSerializer(many=True, context=self.context)
vc._validated_data = venue_constraints # Data was already validated
vc.save(institution=instance)
vc.save(subject=instance)

return super().update(instance, validated_data)

Expand Down

0 comments on commit 8948791

Please sign in to comment.