Skip to content

Commit

Permalink
Merge pull request #72 from wmo-raf/dev
Browse files Browse the repository at this point in the history
Fix getting full url for meta image
  • Loading branch information
erick-otenyo authored Feb 19, 2024
2 parents 33c1030 + 6c469e9 commit 7a98eab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions base/mixins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.utils.translation import gettext_lazy
from wagtail.admin.panels import MultiFieldPanel, FieldPanel
from wagtail.admin.widgets.slug import SlugInput
from wagtail.api.v2.utils import get_full_url
from wagtailcache.cache import WagtailCacheMixin
from wagtailmetadata.models import MetadataPageMixin as BaseMetadataPageMixin

Expand All @@ -27,3 +28,9 @@ class Meta:
gettext_lazy("For site menus"),
),
]

def get_meta_image_url(self, request):
meta_image = self.get_meta_image_rendition()
if meta_image:
return get_full_url(request, meta_image.url)
return None
2 changes: 0 additions & 2 deletions pages/cap/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from datetime import datetime

from capeditor.models import AbstractCapAlertPage
from capeditor.pubsub.publish import publish_cap_mqtt_message
from django.db import models
Expand Down
5 changes: 5 additions & 0 deletions pages/home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ class Meta:
verbose_name = _("Home Page")
verbose_name_plural = _("Home Pages")

def get_meta_image(self):
if self.search_image:
return self.search_image
return self.hero_banner

def get_context(self, request, *args, **kwargs):
context = super(HomePage, self).get_context(
request, *args, **kwargs)
Expand Down

0 comments on commit 7a98eab

Please sign in to comment.