1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 19:55:18 +02:00

feat: Convert activity input to lowercase for consistency

This commit is contained in:
Sean Morley 2024-07-18 11:26:14 -04:00
parent c723d2836d
commit 5e70130000
4 changed files with 44 additions and 18 deletions

View file

@ -42,6 +42,7 @@ class Adventure(models.Model):
raise ValidationError('Adventures associated with a public collection must be public. Collection: ' + self.trip.name + ' Adventure: ' + self.name)
if self.user_id != self.collection.user_id:
raise ValidationError('Adventures must be associated with collections owned by the same user. Collection owner: ' + self.collection.user_id.username + ' Adventure owner: ' + self.user_id.username)
def __str__(self):
return self.name

View file

@ -18,6 +18,11 @@ class AdventureSerializer(serializers.ModelSerializer):
representation['image'] = f"{public_url}/media/{instance.image.name}"
return representation
def validate_activity_types(self, value):
if value:
return [activity.lower() for activity in value]
return value
class CollectionSerializer(serializers.ModelSerializer):
adventures = AdventureSerializer(many=True, read_only=True, source='adventure_set')