Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
9083b76f
Verified
Commit
9083b76f
authored
11 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: expose the image URL as `url` to avoid mixed-content media warnings
parent
35787a13
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/serializers.py
+11
-0
11 additions, 0 deletions
program/serializers.py
with
11 additions
and
0 deletions
program/serializers.py
+
11
−
0
View file @
9083b76f
...
...
@@ -265,6 +265,7 @@ class ImageSerializer(serializers.ModelSerializer):
)
ppoi
=
PPOIField
(
required
=
False
)
thumbnails
=
serializers
.
SerializerMethodField
()
url
=
serializers
.
SerializerMethodField
()
@staticmethod
def
get_thumbnails
(
instance
)
->
List
[
Thumbnail
]:
...
...
@@ -284,12 +285,22 @@ class ImageSerializer(serializers.ModelSerializer):
return
thumbnails
@staticmethod
def
get_url
(
instance
:
Image
)
->
str
:
"""
Returns the image URL, using settings.SITE_URL to include the protocol and avoid mixed
media warnings.
"""
return
f
"
{
settings
.
SITE_URL
}{
instance
.
image
.
url
}
"
class
Meta
:
# TODO: make `image` a write-only field once dashboard is updated to read from `url`
# extra_kwargs = {"image": {"write_only": True}}
model
=
Image
read_only_fields
=
(
"
height
"
,
"
id
"
,
"
thumbnails
"
,
"
url
"
,
"
width
"
,
)
fields
=
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment