Skip to content

Commit

Permalink
Changed all status for delete endpoint and add null to photo_url fiel…
Browse files Browse the repository at this point in the history
…d for pet
  • Loading branch information
riadelimemmedov committed Feb 19, 2024
1 parent 7e3b160 commit 057aeb0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
29 changes: 29 additions & 0 deletions backend/apps/pet/migrations/0004_alter_pet_pet_photo_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 5.0.1 on 2024-02-19 06:15

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("pet", "0003_pet_pet_key_pet_slug"),
]

operations = [
migrations.AlterField(
model_name="pet",
name="pet_photo_url",
field=models.FileField(
blank=True,
null=True,
upload_to="",
validators=[
django.core.validators.FileExtensionValidator(
allowed_extensions=["png", "jpg", "jpeg"]
)
],
verbose_name="Pet photo",
),
),
]
1 change: 1 addition & 0 deletions backend/apps/pet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Pet(TimeStampedModel):
pet_photo_url = models.FileField(
_("Pet photo"),
blank=True,
null=True,
validators=[FileExtensionValidator(allowed_extensions=["png", "jpg", "jpeg"])],
)
location = models.CharField(_("Location"), max_length=50)
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/pet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def put(self, request, slug):
serializer = self.serializer_class(pet, data=request.data)
if serializer.is_valid():
pet = serializer.save()
return Response(self.serializer_class(pet).data)
return Response(self.serializer_class(pet).data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def delete(self, request, slug):
Expand Down

0 comments on commit 057aeb0

Please sign in to comment.