Skip to content
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

Merged
merged 7 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/app/templates/shared/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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 %}
<script>
<script id="messages">
Copy link
Contributor

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?

{% for message in messages %}
setTimeout(function(){
_alert({message: gettext('{{ message }}')}, '{{ message.tags }}');
Expand Down
1 change: 1 addition & 0 deletions app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
re_path(r'^settings/feedback/?', marketing.views.feedback_settings, name='feedback_settings'),
re_path(r'^settings/slack/?', marketing.views.slack_settings, name='slack_settings'),
re_path(r'^settings/ens/?', marketing.views.ens_settings, name='ens_settings'),
re_path(r'^settings/account/?', marketing.views.account_settings, name='account_settings'),
re_path(r'^settings/(.*)?', marketing.views.email_settings, name='settings'),

# marketing views
Expand Down
9 changes: 7 additions & 2 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from urllib.parse import urlsplit

from django.conf import settings
from django.contrib.auth import get_user_model

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -52,6 +53,10 @@
logger = logging.getLogger(__name__)


def get_sentinel_user():
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaptakS Addressed in: 8250d24

return get_user_model().objects.get_or_create(username='deleted')[0]


class BountyQuerySet(models.QuerySet):
"""Handle the manager queryset for Bounties."""

Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just set this to: on_delete=models.SET_NULL - deleted user can only have one associated profile.

data = JSONField()
handle = models.CharField(max_length=255, db_index=True)
last_sync_date = models.DateTimeField(null=True)
Expand Down Expand Up @@ -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={})
Expand Down
28 changes: 28 additions & 0 deletions app/dashboard/templates/ens/account.html
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 %}
52 changes: 51 additions & 1 deletion app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,8 +67,11 @@ def get_settings_navs(request):
'body': 'Slack',
'href': reverse('slack_settings'),
}, {
'body': f"{subdomain}{settings.ENS_TLD}",
'body': f"ENS",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well eliminate the f here.

'href': reverse('ens_settings'),
}, {
'body': f"Account",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

'href': reverse('account_settings'),
}]


Expand Down Expand Up @@ -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'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can eliminate the f string here and above.

logout_redirect = redirect(reverse('logout') + "?next=/")
return logout_redirect
else:
msg = "Error: did not understand your request"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F841 local variable 'msg' is assigned to but never used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to set msg to response['output'] and wrap this in gettext_lazy ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F841 local variable 'msg' is assigned to but never used



context = {

Choose a reason for hiding this comment

The 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, '')

Expand Down
53 changes: 53 additions & 0 deletions app/retail/templates/settings/account.html
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?');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wrap this in trans?

if(!_continue){
e.preventDefault()
return;
}
});
});
</script>
{% endblock %}
2 changes: 2 additions & 0 deletions app/retail/templates/shared/footer_scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<script src="{% static "v2/js/jquery.validate.min.js" %}"></script>
<script src="{% static "v2/js/jsrender.js" %}"></script>
<script src="{% static "v2/js/base.js" %}"></script>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "v2/js/work_with_gitcoin.js" %}"></script>
<script src="{% static "v2/js/animate.min.js" %}"></script>
<script src="{% static "v2/js/note.js" %}"></script>
Expand All @@ -54,3 +55,4 @@
<script>
document.contxt = {{json_context | safe}};
</script>
{% include 'shared/messages.html' %}
1 change: 1 addition & 0 deletions app/retail/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.

'''
from django.contrib import messages

Choose a reason for hiding this comment

The 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
Expand Down