From 1ff59d5d7d247817a2f741e3c5e00536b46d4e8e Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Fri, 3 Aug 2018 22:56:48 -0400 Subject: [PATCH] Add a 'do not track' setting on user profile that will prevent the use of Google Analytics and embedded social media buttons for the user --- events/forms.py | 3 ++- .../0039_add_profile_privacy_option.py | 18 ++++++++++++++++++ events/models/profiles.py | 1 + get_together/templates/get_together/base.html | 11 +++++++---- .../get_together/events/show_event.html | 14 +++++++++++--- .../get_together/orgs/show_common_event.html | 12 +++++++++++- .../get_together/users/edit_profile.html | 16 ++++++++++++++++ 7 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 events/migrations/0039_add_profile_privacy_option.py diff --git a/events/forms.py b/events/forms.py index fcd3405..ed76f2c 100644 --- a/events/forms.py +++ b/events/forms.py @@ -333,9 +333,10 @@ class UserForm(forms.ModelForm): class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile - fields = ['avatar', 'realname', 'city', 'tz', 'send_notifications'] + fields = ['avatar', 'realname', 'city', 'tz', 'send_notifications', 'do_not_track'] labels = { 'send_notifications': _('Send me notification emails'), + 'do_not_track': _('Do not track'), } widgets = { 'city': Lookup(source=City), diff --git a/events/migrations/0039_add_profile_privacy_option.py b/events/migrations/0039_add_profile_privacy_option.py new file mode 100644 index 0000000..8b81526 --- /dev/null +++ b/events/migrations/0039_add_profile_privacy_option.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0 on 2018-08-04 02:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('events', '0038_add_common_event_continent'), + ] + + operations = [ + migrations.AddField( + model_name='userprofile', + name='do_not_track', + field=models.BooleanField(default=False, verbose_name='Do not track'), + ), + ] diff --git a/events/models/profiles.py b/events/models/profiles.py index c8dd59e..d08cd74 100644 --- a/events/models/profiles.py +++ b/events/models/profiles.py @@ -39,6 +39,7 @@ class UserProfile(models.Model): facebook = models.URLField(verbose_name=_('Facebook URL'), max_length=32, blank=True, null=True) send_notifications = models.BooleanField(verbose_name=_('Send notification emails'), default=True) + do_not_track = models.BooleanField(verbose_name=_("Do not track"), default=False) secret_key = models.UUIDField(default=uuid.uuid4, editable=True) diff --git a/get_together/templates/get_together/base.html b/get_together/templates/get_together/base.html index 3763bf6..9f41928 100644 --- a/get_together/templates/get_together/base.html +++ b/get_together/templates/get_together/base.html @@ -12,7 +12,7 @@ {% block meta %}{% endblock %} - {% if settings.GOOGLE_ANALYTICS_ID %} + {% if settings.GOOGLE_ANALYTICS_ID and not request.user.profile.do_not_track %} + {% else %} + {% comment %}delete any analytics events recorded in this session" {% endcomment %} + {% for event in ga_events %}{% endfor %} {% endif %} + {% block scripts %}{% endblock %} + @@ -37,9 +42,7 @@ - {%block styles %}{% endblock %} - + {% block styles %}{% endblock %} diff --git a/get_together/templates/get_together/events/show_event.html b/get_together/templates/get_together/events/show_event.html index 9f87372..45e1f0c 100644 --- a/get_together/templates/get_together/events/show_event.html +++ b/get_together/templates/get_together/events/show_event.html @@ -28,6 +28,10 @@ } +{% endblock %} + +{% block scripts %} +{% if not request.user.profile.do_not_track %} {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} {% endif %} + {% if settings.SOCIAL_AUTH_TWITTER_KEY %} {% endif %} -{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %} +{% if settings.SOCIAL_AUTH_LINKEDIN_KEY %} {% endif %} + +{% endif %} + +{% endif %} {% endblock %} {% block content %} @@ -108,7 +116,7 @@

{{ event.name }}

{% endif %}

Hosted by {{ team.name }}

- {% if event.status != event.CANCELED %} + {% if event.status != event.CANCELED and not request.user.profile.do_not_track %} {% if settings.SOCIAL_AUTH_TWITTER_KEY %} Tweet {% endif %} diff --git a/get_together/templates/get_together/orgs/show_common_event.html b/get_together/templates/get_together/orgs/show_common_event.html index ec7d6d0..f159eec 100644 --- a/get_together/templates/get_together/orgs/show_common_event.html +++ b/get_together/templates/get_together/orgs/show_common_event.html @@ -26,6 +26,10 @@ border-top: none; } +{% endblock %} + +{% block scripts %} +{% if not request.user.profile.do_not_track %} {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} {% endif %} + {% if settings.SOCIAL_AUTH_TWITTER_KEY %} -{% endif %}{% endblock %} +{% endif %} + +{% endif %} +{% endblock %} {% block content %}
@@ -94,12 +102,14 @@ {% endif %}
+ {% if not request.user.profile.do_not_track %} {% if settings.SOCIAL_AUTH_TWITTER_KEY %} Tweet {% endif %} {% if settings.SOCIAL_AUTH_FACEBOOK_KEY %} Share {% endif %} + {% endif %}
diff --git a/get_together/templates/get_together/users/edit_profile.html b/get_together/templates/get_together/users/edit_profile.html index 218b308..8ca8f92 100644 --- a/get_together/templates/get_together/users/edit_profile.html +++ b/get_together/templates/get_together/users/edit_profile.html @@ -53,6 +53,22 @@ $(document).ready(function(){ } }); $("#id_tz").selectmenu() + + $("#id_send_notifications").change(function(event) { + if (!this.checked) { + if (!window.confirm("If you opt out you will not receive emails reminding you of your upcoming events, when people join your team, or interact with your events.\n\nAre you sure you want to do this?")) { + this.checked = true; + } + } + }); + + $("#id_do_not_track").change(function(event) { + if (this.checked) { + if (!window.confirm("By opting out of tracking, your activity will not be included in site analytics that we use to improve GetTogether, and you will not you be shown sharing buttons that make it easy to promote teams and events to your social media accounts.\n\nAre you sure you want to do this?")) { + this.checked = false; + } + } + }); }); {% endblock %}