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 @@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 %}