From 19f4dbf3133a3c94edaa198fa9483c3701a049cb Mon Sep 17 00:00:00 2001 From: Owocki Date: Wed, 23 May 2018 15:26:29 -0600 Subject: [PATCH 1/6] GDPR: Fixes https://github.com/gitcoinco/web/issues/1243 --- app/app/templates/shared/messages.html | 2 +- app/app/urls.py | 1 + app/dashboard/models.py | 9 +++- app/dashboard/templates/ens/account.html | 28 ++++++++++ app/marketing/views.py | 52 +++++++++++++++++- app/retail/templates/settings/account.html | 53 +++++++++++++++++++ .../templates/shared/footer_scripts.html | 2 + app/retail/views.py | 1 + 8 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 app/dashboard/templates/ens/account.html create mode 100644 app/retail/templates/settings/account.html diff --git a/app/app/templates/shared/messages.html b/app/app/templates/shared/messages.html index 854065577d3..9a5ce308fb2 100644 --- a/app/app/templates/shared/messages.html +++ b/app/app/templates/shared/messages.html @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . {% endcomment %} - + + {% block 'ens_script' %} + {% endblock %} +{% endblock %} + +{% block 'main' %} +
+ {% include 'shared/current_balance.html' %} +
+
+
+
+ + + + + +
+
+ {% block 'body_block' %} + {% endblock %} +
+
+{% endblock %} diff --git a/app/marketing/views.py b/app/marketing/views.py index cd43f77b875..eca64d520fa 100644 --- a/app/marketing/views.py +++ b/app/marketing/views.py @@ -23,6 +23,7 @@ import random from django.conf import settings +from django.contrib import messages from django.contrib.admin.views.decorators import staff_member_required from django.contrib.auth.decorators import login_required from django.core.validators import validate_email @@ -66,8 +67,11 @@ def get_settings_navs(request): 'body': 'Slack', 'href': reverse('slack_settings'), }, { - 'body': f"{subdomain}{settings.ENS_TLD}", + 'body': f"ENS", 'href': reverse('ens_settings'), + }, { + 'body': f"Account", + 'href': reverse('account_settings'), }] @@ -389,6 +393,52 @@ def ens_settings(request): return TemplateResponse(request, 'settings/ens.html', context) +def account_settings(request): + """Displays and saves user's Account settings. + + Returns: + TemplateResponse: The user's Account settings template response. + + """ + response = {'output': ''} + profile, es, user, is_logged_in = settings_helper_get_auth(request) + + if not user or not is_logged_in: + login_redirect = redirect('/login/github?next=' + request.get_full_path()) + return login_redirect + + if request.POST: + + if request.POST.get('disconnect', False): + profile.github_access_token = '' + profile.save() + messages.success(request, _(f'Your account has been disconnected from Github')) + logout_redirect = redirect(reverse('logout') + "?next=/") + return logout_redirect + if request.POST.get('delete', False): + profile.hide_profile = True + profile.save() + request.user.delete() + messages.success(request, _(f'Your account has been deleted')) + logout_redirect = redirect(reverse('logout') + "?next=/") + return logout_redirect + else: + msg = "Error: did not understand your request" + + + context = { + 'is_logged_in': is_logged_in, + 'nav': 'internal', + 'active': '/settings/account', + 'title': _('Account Settings'), + 'navs': get_settings_navs(request), + 'es': es, + 'profile': profile, + 'msg': response['output'], + } + return TemplateResponse(request, 'settings/account.html', context) + + def _leaderboard(request): return leaderboard(request, '') diff --git a/app/retail/templates/settings/account.html b/app/retail/templates/settings/account.html new file mode 100644 index 00000000000..f3d4645ab35 --- /dev/null +++ b/app/retail/templates/settings/account.html @@ -0,0 +1,53 @@ +{% extends 'settings/settings.html' %} +{% load i18n static %} +{% block settings_content %} + +
+
{% trans " Account Settings" %}
+
+
+
+
+ {% csrf_token %} + +
+
{% trans "Github" %}
+

{% trans "Connected as " %}{{github_handle}}

+
+
+
+
+
+ {% csrf_token %} + +
+
{% trans "Delete My Account" %}
+

{% trans "This action deletes all of your data" %}

+
+
+ +{% endblock %} +{% block scripts %} + +{% endblock %} diff --git a/app/retail/templates/shared/footer_scripts.html b/app/retail/templates/shared/footer_scripts.html index fd3ada58e13..b59bfbad505 100644 --- a/app/retail/templates/shared/footer_scripts.html +++ b/app/retail/templates/shared/footer_scripts.html @@ -28,6 +28,7 @@ + @@ -54,3 +55,4 @@ + {% include 'shared/messages.html' %} diff --git a/app/retail/views.py b/app/retail/views.py index 4e07cee20c1..c9c65dbf037 100644 --- a/app/retail/views.py +++ b/app/retail/views.py @@ -16,6 +16,7 @@ along with this program. If not, see . ''' +from django.contrib import messages from django.contrib.staticfiles.templatetags.staticfiles import static from django.core.exceptions import ValidationError from django.core.validators import validate_email From c37070f16c5a3deff1125e3861147eb99dda7100 Mon Sep 17 00:00:00 2001 From: Mark Beacom Date: Thu, 24 May 2018 09:08:04 -0400 Subject: [PATCH 2/6] Update per comments --- app/dashboard/models.py | 4 ++-- app/marketing/views.py | 19 +++++++++---------- app/retail/views.py | 1 - 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 7e4d714d25f..0e41cd41fc7 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -913,7 +913,7 @@ class Profile(SuperModel): """ - user = models.OneToOneField(User, on_delete=models.SET(get_sentinel_user), null=True, blank=True) + user = models.OneToOneField(User, on_delete=models.SET_NULL, null=True, blank=True) data = JSONField() handle = models.CharField(max_length=255, db_index=True) last_sync_date = models.DateTimeField(null=True) @@ -1285,7 +1285,7 @@ class UserAction(SuperModel): ('removed_slack_integration', 'Removed Slack Integration'), ] action = models.CharField(max_length=50, choices=ACTION_TYPES) - user = models.ForeignKey(User, related_name='actions', on_delete=models.SET(get_sentinel_user), null=True) + user = models.ForeignKey(User, related_name='actions', on_delete=models.SET_NULL, null=True) profile = models.ForeignKey('dashboard.Profile', related_name='actions', on_delete=models.CASCADE, null=True) ip_address = models.GenericIPAddressField(null=True) location_data = JSONField(default={}) diff --git a/app/marketing/views.py b/app/marketing/views.py index eca64d520fa..18574adf8f0 100644 --- a/app/marketing/views.py +++ b/app/marketing/views.py @@ -67,10 +67,10 @@ def get_settings_navs(request): 'body': 'Slack', 'href': reverse('slack_settings'), }, { - 'body': f"ENS", + 'body': "ENS", 'href': reverse('ens_settings'), }, { - 'body': f"Account", + 'body': "Account", 'href': reverse('account_settings'), }] @@ -400,7 +400,7 @@ def account_settings(request): TemplateResponse: The user's Account settings template response. """ - response = {'output': ''} + msg = '' profile, es, user, is_logged_in = settings_helper_get_auth(request) if not user or not is_logged_in: @@ -412,19 +412,18 @@ def account_settings(request): if request.POST.get('disconnect', False): profile.github_access_token = '' profile.save() - messages.success(request, _(f'Your account has been disconnected from Github')) - logout_redirect = redirect(reverse('logout') + "?next=/") + messages.success(request, _('Your account has been disconnected from Github')) + logout_redirect = redirect(reverse('logout') + '?next=/') return logout_redirect if request.POST.get('delete', False): profile.hide_profile = True profile.save() request.user.delete() - messages.success(request, _(f'Your account has been deleted')) - logout_redirect = redirect(reverse('logout') + "?next=/") + messages.success(request, _('Your account has been deleted')) + logout_redirect = redirect(reverse('logout') + '?next=/') return logout_redirect else: - msg = "Error: did not understand your request" - + msg = _('Error: did not understand your request') context = { 'is_logged_in': is_logged_in, @@ -434,7 +433,7 @@ def account_settings(request): 'navs': get_settings_navs(request), 'es': es, 'profile': profile, - 'msg': response['output'], + 'msg': msg, } return TemplateResponse(request, 'settings/account.html', context) diff --git a/app/retail/views.py b/app/retail/views.py index c9c65dbf037..4e07cee20c1 100644 --- a/app/retail/views.py +++ b/app/retail/views.py @@ -16,7 +16,6 @@ along with this program. If not, see . ''' -from django.contrib import messages from django.contrib.staticfiles.templatetags.staticfiles import static from django.core.exceptions import ValidationError from django.core.validators import validate_email From ede1eb531de8bb066ac34ad7e9c30b77a9a53abc Mon Sep 17 00:00:00 2001 From: Mark Beacom Date: Thu, 24 May 2018 09:25:58 -0400 Subject: [PATCH 3/6] Update remaining trans --- app/retail/templates/settings/account.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/retail/templates/settings/account.html b/app/retail/templates/settings/account.html index f3d4645ab35..c2591a5e11a 100644 --- a/app/retail/templates/settings/account.html +++ b/app/retail/templates/settings/account.html @@ -42,7 +42,7 @@
{% trans "Delete My Account" %}