-
-
Notifications
You must be signed in to change notification settings - Fork 775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDPR: Fixes https://github.com/gitcoinco/web/issues/1243 #1246
Changes from 1 commit
19f4dbf
5332e74
c37070f
ede1eb5
8250d24
54d9b7c
3fbdb12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
from urllib.parse import urlsplit | ||
|
||
from django.conf import settings | ||
from django.contrib.auth import get_user_model | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F401 'django.contrib.auth.get_user_model' imported but unused |
||
from django.contrib.auth.models import User | ||
from django.contrib.auth.signals import user_logged_in, user_logged_out | ||
from django.contrib.humanize.templatetags.humanize import naturalday, naturaltime | ||
|
@@ -52,6 +53,10 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_sentinel_user(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove this function if we are using SET_NULL. @mbeacom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return get_user_model().objects.get_or_create(username='deleted')[0] | ||
|
||
|
||
class BountyQuerySet(models.QuerySet): | ||
"""Handle the manager queryset for Bounties.""" | ||
|
||
|
@@ -908,7 +913,7 @@ class Profile(SuperModel): | |
|
||
""" | ||
|
||
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True) | ||
user = models.OneToOneField(User, on_delete=models.SET(get_sentinel_user), null=True, blank=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just set this to: |
||
data = JSONField() | ||
handle = models.CharField(max_length=255, db_index=True) | ||
last_sync_date = models.DateTimeField(null=True) | ||
|
@@ -1267,7 +1272,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.CASCADE, null=True) | ||
user = models.ForeignKey(User, related_name='actions', on_delete=models.SET(get_sentinel_user), 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={}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'ens/base.html' %} | ||
{% load i18n static %} | ||
{% block 'scripts' %} | ||
<script src="{% static 'v2/js/shared.js' %}"></script> | ||
<script src="{% static 'ens/index.js' %}"></script> | ||
{% block 'ens_script' %} | ||
{% endblock %} | ||
{% endblock %} | ||
<!-- Main --> | ||
{% block 'main' %} | ||
<section> | ||
{% include 'shared/current_balance.html' %} | ||
</section> | ||
<br> | ||
<section id="main" class="mt-2"> | ||
<header> | ||
<span class="avatar"> | ||
<a href="{% url 'ens' %}"> | ||
<img src="{% static 'v2/images/ens.png' %}" style="background-color: white; max-width: 150px; max-height: 150px;" /> | ||
</a> | ||
</span> | ||
</header> | ||
<div id="ens_subdomain"> | ||
{% block 'body_block' %} | ||
{% endblock %} | ||
</div> | ||
</section> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might as well eliminate the |
||
'href': reverse('ens_settings'), | ||
}, { | ||
'body': f"Account", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
'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')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can eliminate the |
||
logout_redirect = redirect(reverse('logout') + "?next=/") | ||
return logout_redirect | ||
else: | ||
msg = "Error: did not understand your request" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F841 local variable 'msg' is assigned to but never used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F841 local variable 'msg' is assigned to but never used |
||
|
||
|
||
context = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E303 too many blank lines (2) |
||
'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, '') | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{% extends 'settings/settings.html' %} | ||
{% load i18n static %} | ||
{% block settings_content %} | ||
<style type="text/css"> | ||
.major_button_container{ | ||
border: 1px solid #090909; | ||
padding: 20px; | ||
} | ||
.major_button_container input{ | ||
float: right; | ||
} | ||
.major_button_container input.warning{ | ||
background-color: #ca001a; | ||
} | ||
</style> | ||
<div class="form-group"> | ||
<h5>{% trans " Account Settings" %}</h5> | ||
</div> | ||
<div class="form-group"> | ||
<div class="major_button_container"> | ||
<form id="disconnect" method="POST" action="{% url 'account_settings' %}"> | ||
{% csrf_token %} | ||
<input type="submit" class="button button--primary" name="disconnect" value="Disconnect"> | ||
</form> | ||
<h5>{% trans "Github" %}</h5> | ||
<p>{% trans "Connected as " %}{{github_handle}}</p> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="major_button_container"> | ||
<form id="delete" method="POST" action="{% url 'account_settings' %}"> | ||
{% csrf_token %} | ||
<input type="submit" class="button button--primary warning" name="delete" value="Delete"> | ||
</form> | ||
<h5>{% trans "Delete My Account" %}</h5> | ||
<p>{% trans "This action deletes all of your data" %}</p> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
{% block scripts %} | ||
<script> | ||
$("document").ready(function(){ | ||
$("#delete").submit(function(e){ | ||
var _continue = confirm('Are you sure you want to delete all of your data from Gitcoin?'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we wrap this in |
||
if(!_continue){ | ||
e.preventDefault() | ||
return; | ||
} | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
''' | ||
from django.contrib import messages | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. F401 'django.contrib.messages' imported but unused |
||
from django.contrib.staticfiles.templatetags.staticfiles import static | ||
from django.core.exceptions import ValidationError | ||
from django.core.validators import validate_email | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this change do?