From d2317c8ed913d64274df2b8d265e6ad2bb5f272a Mon Sep 17 00:00:00 2001 From: Anas Hameed <68567262+Anas-hameed@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:15:47 +0500 Subject: [PATCH] Get panel-backend url from lms site configuration (#511) Co-authored-by: Anas-hameed --- openedx/features/edly/api/serializers.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openedx/features/edly/api/serializers.py b/openedx/features/edly/api/serializers.py index e37616dcb7bb..436a03924b31 100644 --- a/openedx/features/edly/api/serializers.py +++ b/openedx/features/edly/api/serializers.py @@ -2,11 +2,14 @@ Serializers for edly_api """ import json +import logging from rest_framework import serializers +from openedx.core.djangoapps.site_configuration.models import SiteConfiguration from openedx.features.edly.models import EdlyMultiSiteAccess from openedx.features.edly.utils import get_marketing_link +LOGGER = logging.getLogger(__name__) class UserSiteSerializer(serializers.Serializer): @@ -59,10 +62,20 @@ class MutiSiteAccessSerializer(serializers.ModelSerializer): name = serializers.CharField(source='sub_org.name', read_only=True) slug = serializers.CharField(source='sub_org.slug', read_only=True) + panel_base_url = serializers.SerializerMethodField() + + def get_panel_base_url(self, instance): + """Add support to get the panel_base_url from site configuration""" + site_configuration = dict(SiteConfiguration.objects.filter(site=instance.sub_org.lms_site).first().site_values) + notification_url = site_configuration.get('PANEL_NOTIFICATIONS_BASE_URL', '') + if not notification_url: + LOGGER.info("Current site have no notification url") + + return notification_url if notification_url.endswith("/") else f"{notification_url}/" class Meta: """ Meta attribute for the MutiSiteAccess Model """ model = EdlyMultiSiteAccess - fields = ['id', 'name', 'slug'] + fields = ['id', 'name', 'slug', 'panel_base_url']