Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include BASE_URL in image file serialization #1093

Merged
merged 9 commits into from
Jun 11, 2024
2 changes: 1 addition & 1 deletion backend/aml/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@
}
}

SUBPATH = os.getenv('AML_SUBPATH', None)
SUBPATH = os.getenv('AML_SUBPATH', '')
drikusroor marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion backend/image/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def serialize_image(image: Image) -> dict:
return {
'file': join(settings.MEDIA_URL, str(image.file)),
'file': join(settings.MEDIA_URL, settings.SUBPATH, str(image.file)),
'href': image.href,
'alt': image.alt,
}
12 changes: 2 additions & 10 deletions backend/theme/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from django_markup.markup import formatter

from image.models import Image
from image.serializers import serialize_image
from theme.models import FooterConfig, HeaderConfig, ThemeConfig


Expand All @@ -14,21 +14,13 @@ def serialize_footer(footer: FooterConfig) -> dict:
'disclaimer': formatter(
footer.disclaimer, filter_name='markdown'),
'logos': [
serialize_logo(logo) for logo in footer.logos.all()
serialize_image(logo) for logo in footer.logos.all()
],
'privacy': formatter(
footer.privacy, filter_name='markdown'),
}


def serialize_logo(logo: Image) -> dict:
return {
'file': join(settings.MEDIA_URL, str(logo.file)),
'href': logo.href,
'alt': logo.alt,
}


def serialize_header(header: HeaderConfig) -> dict:
return {
'nextExperimentButtonText': _('Next experiment'),
Expand Down
Loading