#51 feat: add editable store logo to StoreSettings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.conf import settings
|
||||
from rest_framework import serializers
|
||||
|
||||
from ..models.store_settings import StoreSettings
|
||||
@@ -6,5 +7,16 @@ from ..models.store_settings import StoreSettings
|
||||
class StoreSettingsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = StoreSettings
|
||||
fields = ["id", "address", "latitude", "longitude", "updated_at"]
|
||||
fields = ["id", "address", "latitude", "longitude", "logo", "updated_at"]
|
||||
read_only_fields = ["id", "updated_at"]
|
||||
|
||||
def validate_logo(self, value):
|
||||
if value is None:
|
||||
return value
|
||||
max_size = settings.LOGO_MAX_UPLOAD_SIZE
|
||||
if value.size > max_size:
|
||||
raise serializers.ValidationError(
|
||||
f"Logo size exceeds the maximum allowed size of "
|
||||
f"{max_size // (1024 * 1024)}MB."
|
||||
)
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user