Skip to content

Commit

Permalink
GDPR: Management command to send email to all gitcoin users
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS committed May 24, 2018
1 parent 86a9011 commit 82dbf51
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 3 deletions.
21 changes: 18 additions & 3 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from python_http_client.exceptions import HTTPError, UnauthorizedError
from retail.emails import (
render_bounty_expire_warning, render_bounty_feedback, render_bounty_startwork_expire_warning,
render_bounty_unintersted, render_faucet_rejected, render_faucet_request, render_match_email, render_new_bounty,
render_new_bounty_acceptance, render_new_bounty_rejection, render_new_bounty_roundup, render_new_work_submission,
render_tip_email,
render_bounty_unintersted, render_faucet_rejected, render_faucet_request, render_gdpr_update,
render_match_email, render_new_bounty, render_new_bounty_acceptance, render_new_bounty_rejection,
render_new_bounty_roundup, render_new_work_submission, render_tip_email,
)
from sendgrid.helpers.mail import Content, Email, Mail, Personalization

Expand Down Expand Up @@ -241,6 +241,21 @@ def weekly_roundup(to_emails=None):
translation.activate(cur_language)


def gdpr_update(to_emails=None):
if to_emails is None:
to_emails = []

for to_email in to_emails:
cur_language = translation.get_language()
try:
setup_lang(to_email)
html, text, subject = render_gdpr_update(to_email)
from_email = settings.PERSONAL_CONTACT_EMAIL
send_mail(from_email, to_email, subject, text, html, from_name="Kevin Owocki (Gitcoin.co)")
finally:
translation.activate(cur_language)


def new_work_submission(bounty, to_emails=None):
if not bounty or not bounty.value_in_usdt_now:
return
Expand Down
80 changes: 80 additions & 0 deletions app/marketing/management/commands/gdpr_update_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
'''
Copyright (C) 2017 Gitcoin Core
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import time
import warnings

from django.core.management.base import BaseCommand

from marketing.mails import gdpr_update
from marketing.models import EmailSubscriber

warnings.filterwarnings("ignore", category=DeprecationWarning)


class Command(BaseCommand):

help = 'the gdpr policy update email'

def add_arguments(self, parser):
parser.add_argument(
'-live', '--live',
action='store_true',
dest='live',
default=False,
help='Actually Send the emails'
)
parser.add_argument(
'--exclude_startswith',
dest='exclude_startswith',
type=str,
default=None,
help="exclude_startswith (optional)",
)
parser.add_argument(
'--filter_startswith',
dest='filter_startswith',
type=str,
default=None,
help="filter_startswith (optional)",
)

def handle(self, *args, **options):
exclude_startswith = options['exclude_startswith']
filter_startswith = options['filter_startswith']

queryset = EmailSubscriber.objects.filter(newsletter=True)
if exclude_startswith:
queryset = queryset.exclude(email__startswith=exclude_startswith)
if filter_startswith:
queryset = queryset.filter(email__startswith=filter_startswith)
queryset = queryset.order_by('email')
email_list = set(queryset.values_list('email', flat=True))

print(f'got {len(email_list)} emails')

counter = 0
for to_email in email_list:
counter += 1
print(f'-sending {counter} / {to_email}')
if options['live']:
try:
gdpr_update([to_email])
time.sleep(1)
except Exception as e:
print(e)
time.sleep(5)
15 changes: 15 additions & 0 deletions app/retail/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,21 @@ def render_bounty_startwork_expired(to_email, bounty, interest, time_delta_days)
return response_html, response_txt


def render_gdpr_update(to_email):
params = {
'subscriber': get_or_save_email_subscriber(to_email, 'internal'),
'terms_of_use_link': '',
'privacy_policy_link': '',
'cookie_policy_link': '',
}

subject = "Gitcoin: Updated Terms & Policies"
response_html = premailer_transform(render_to_string("emails/gdpr_update.html", params))
response_txt = render_to_string("emails/gdpr_update.txt", params)

return response_html, response_txt, subject


# ROUNDUP_EMAIL
def render_new_bounty_roundup(to_email):
from dashboard.models import Bounty
Expand Down
54 changes: 54 additions & 0 deletions app/retail/templates/emails/gdpr_update.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% extends 'emails/template.html' %}
{% comment %}
Copyright (C) 2017 Gitcoin Core

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

{% endcomment %}
{% load i18n humanize %}
{% load static %}

{% block content %}

<h1>{% trans "Gitcoin: Updated Terms & Policies" %}</h1>
<div style="text-align: left! important">
<p>
{% trans "Hello" %} {{ subscriber }},
</p>
<p>
{% trans "As a Web 3.0 company, we think carefully about user data and privacy and how the internet is evolving. We hope Web 3.0 will bring more control of data to users. With this ethos, we are always careful about how we use your information. " %}
</p>
<p>
{% trans "We recently reviewed our Privacy Policy to comply with requirements of General Data Protection Regulation (GDPR), improving our Terms of Use, Privacy Policy and Cookie Policy. These changes will go into effect on May 25, 2018, and your continued use of the Gitcoin after May 25, 2018 will be subject to our updated Terms of Use and Privacy Policy. " %}
</p>
<p>
{% trans "As always, the entire Gitcoin team works every day to make Gitcoin a safe and trustworthy place to grow open source. We invite you to learn more about our outlined updates to our Policies and Terms of Use: " %}
</p>
<ul>
<li><a href="{{ terms_of_use_link }}">{% trans "Our updated Terms of Use " %}</a></li>
<li><a href="{{ privacy_policy_link }}">{% trans "Our updated Privacy Policy " %}</a></li>
<li><a href="{{ cookie_policy_link }}">{% trans "Our updated Cookie Policy " %}</a></li>
</ul>

<p>
{% trans "We’ll continue to keep you updated on our data privacy policies on the path towards a more open, transparent web. Thanks for using Gitcoin, and please let us know if you have any questions or feedback. " %}
</p>
<p>
{% blocktrans %}
Warmly, <br>
Gitcoin Core
{% endblocktrans %}
</p>
</div>
{% endblock %}
20 changes: 20 additions & 0 deletions app/retail/templates/emails/gdpr_update.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Hello {{ subscriber }},

As a Web 3.0 company, we think carefully about user data and privacy and how the internet is evolving. We hope Web 3.0 will bring more control of data to users. With this ethos, we are always careful about how we use your information.

We recently reviewed our Privacy Policy to comply with requirements of General Data Protection Regulation (GDPR), improving our Terms of Use, Privacy Policy and Cookie Policy. These changes will go into effect on May 25, 2018, and your continued use of the Gitcoin after May 25, 2018 will be subject to our updated Terms of Use and Privacy Policy.

As always, the entire Gitcoin team works every day to make Gitcoin a safe and trustworthy place to grow open source. We invite you to learn more about our outlined updates to our Policies and Terms of Use:

1) Our updated Terms of Use [1]
2) Our updated Privacy Policy [2]
3) Our updated Cookie Policy [3]

We’ll continue to keep you updated on our data privacy policies on the path towards a more open, transparent web. Thanks for using Gitcoin, and please let us know if you have any questions or feedback.

[1] {{ terms_of_use_link }}
[2] {{ privacy_policy_link }}
[3] {{ cookie_policy_link }}

Warmly,
Gitcoin Core

0 comments on commit 82dbf51

Please sign in to comment.