From 98dd7558c6655cd69d7b705e95d4eceb1075b0ec Mon Sep 17 00:00:00 2001 From: nosanity Date: Mon, 31 May 2021 17:54:16 +0300 Subject: [PATCH 1/2] =?UTF-8?q?PLP-24=20MK=20-=20=D0=A3=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B8=D1=82=D1=8C=20GTM=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B2?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=B3=D0=BE=20=D0=B0=D0=B9=D0=B4=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=20(=20Edu))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sso_edx_tp/backends/tp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sso_edx_tp/backends/tp.py b/sso_edx_tp/backends/tp.py index 2c11648..4c33d81 100644 --- a/sso_edx_tp/backends/tp.py +++ b/sso_edx_tp/backends/tp.py @@ -43,6 +43,7 @@ class TpBackend(BaseOAuth2): EXTRA_DATA = [ ('refresh_token', 'refresh_token', True), ('expires_in', 'expires'), + ('gtm_id', 'gtm_id', True), ] PIPELINE = DEFAULT_AUTH_PIPELINE From 5277242862675539a42dac413ade513835a3ed7c Mon Sep 17 00:00:00 2001 From: nosanity Date: Mon, 31 May 2021 19:29:17 +0300 Subject: [PATCH 2/2] =?UTF-8?q?EDX-44=20MK=20=E2=80=93=20=D0=A3=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=B8=D1=82=D1=8C=20GTM=20=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D0=B2=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=20=D0=B2=20=D0=BD=D0=B5=D0=B3=D0=BE=20=D0=B0=D0=B9=D0=B4=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F=20(=20Edu))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sso_edx_tp/context_processors.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sso_edx_tp/context_processors.py diff --git a/sso_edx_tp/context_processors.py b/sso_edx_tp/context_processors.py new file mode 100644 index 0000000..776f2ee --- /dev/null +++ b/sso_edx_tp/context_processors.py @@ -0,0 +1,16 @@ +from django.conf import settings + + +def edx_context(request): + gtm_id = None + if request.user.is_authenticated(): + items = request.user.social_auth.filter(provider__in=('sso_tp-oauth2', 'sso_tp_cms-oauth2')) + for item in items: + if isinstance(item.extra_data, dict) and isinstance(item.extra_data.get('gtm_id'), str) and item.extra_data.get('gtm_id'): + gtm_id = item.extra_data.get('gtm_id') + break + return { + 'USER_GTM_ID': gtm_id, + 'INCLUDE_ADDITIONAL_JS_CODE': getattr(settings, 'ADDITIONAL_JS_CODE', None), + } +