From c34d429f57cfc00a84fd4e51079701071415f64f Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Mon, 20 Aug 2018 16:59:31 +0200 Subject: [PATCH] Enable Intercom for anonymous users Update tests to add conventional test_render_internal_ip. --- analytical/templatetags/intercom.py | 5 +---- analytical/tests/test_tag_intercom.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/analytical/templatetags/intercom.py b/analytical/templatetags/intercom.py index 2993bd4..f0f50d1 100644 --- a/analytical/templatetags/intercom.py +++ b/analytical/templatetags/intercom.py @@ -74,16 +74,13 @@ class IntercomNode(Node): return params def render(self, context): - user = get_user_from_context(context) params = self._get_custom_attrs(context) params["app_id"] = self.app_id html = TRACKING_CODE % { "settings_json": json.dumps(params, sort_keys=True) } - if is_internal_ip(context, 'INTERCOM') \ - or not user or not get_user_is_authenticated(user): - # Intercom is disabled for non-logged in users. + if is_internal_ip(context, 'INTERCOM'): html = disable_html(html, 'Intercom') return html diff --git a/analytical/tests/test_tag_intercom.py b/analytical/tests/test_tag_intercom.py index 586df6a..bc24739 100644 --- a/analytical/tests/test_tag_intercom.py +++ b/analytical/tests/test_tag_intercom.py @@ -4,7 +4,8 @@ Tests for the intercom template tags and filters. import datetime -from django.contrib.auth.models import User, AnonymousUser +from django.contrib.auth.models import User +from django.http import HttpRequest from django.template import Context from django.test.utils import override_settings @@ -21,7 +22,7 @@ class IntercomTagTestCase(TagTestCase): def test_tag(self): rendered_tag = self.render_tag('intercom', 'intercom') - self.assertTrue(rendered_tag.startswith(''), r)