Skip to content

Commit

Permalink
Merge pull request #152 from womenhackfornonprofits/development
Browse files Browse the repository at this point in the history
Merging development into master for the next release
  • Loading branch information
mybits committed Jun 9, 2018
2 parents d2a68cb + 47229cd commit 5ac293d
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 20 deletions.
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Contributing Guidelines
1. Come say hi in the #ocd-action Slack channel before grabbing a ticket
2. Fork the repository or ask to be added to the team on Github (you will need to have a github account and share your github username)
3. Assign an issue to yourself and start working. All changes must be done on a new branch so you can raise a PR.
3. Assign an issue to yourself and start working. All changes must be done on a new branch so you can raise a PR. Checkout a new branch from `development` branch (which is our pre-production branch).
4. Once ready, please raise a Pull Request.

# How to raise a Pull Request
In order to raise a Pull Request with your changes (please make sure all changes are done on a branch):

- Save and commit your changes
- Push your changes and create a pull request: `git push origin your_branch_name`
- Go to the [repo](https://github.com/womenhackfornonprofits/london-cafes-django) and you should see a green button "Raise a Pull Request"
- Go to the [repo](https://github.com/womenhackfornonprofits/ocdaction) and you should see a green button "Raise a Pull Request"
![](https://help.github.com/assets/images/help/pull_requests/pull-request-click-to-create.png)
- Change a base branch from `master` to `development`
- Describe all the changes you have made in details and save.
1 change: 0 additions & 1 deletion ocdaction/.cache/v/cache/lastfailed

This file was deleted.

22 changes: 11 additions & 11 deletions ocdaction/challenges/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
"""
from django.conf.urls import url

from .views import (
challenge_list,
challenge_list_archived,
challenge_add,
challenge_view,
challenge_edit,
challenge_archive,
challenge_score_form_new,
challenge_score_form,
challenge_summary
)
from .views import *

urlpatterns = [
url(
Expand Down Expand Up @@ -61,4 +51,14 @@
challenge_summary,
name="challenge-summary"
),
url(
r'^erase-my-record/$',
challenge_erase_my_record,
name="challenge-erase-my-record"
),
url(
r'^delete-users-challenges/$',
delete_users_challenges,
name="delete-users-challenges"
),
]
24 changes: 24 additions & 0 deletions ocdaction/challenges/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,27 @@ def challenge_score_form(request, challenge_id, score_id):
'challenge/challenge_score_form.html',
context
)

@login_required
def challenge_erase_my_record(request):
return render(request, 'challenge/challenge_erase_my_record.html')

def delete_challenges(user):

challenges = Challenge.objects.filter(user=user)

for challenge in challenges:
challenge.delete()

@login_required
def delete_users_challenges(request):
"""
Delete all challenges and associated score cards for a user
"""
delete_challenges(request.user)

return render(request, 'profiles/my_account_confirm.html', {'deleted_user': False})




2 changes: 1 addition & 1 deletion ocdaction/ocdaction/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

DEBUG = True

#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

LOGGING = {
'version': 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "layout.html" %}

{% load static %}
{% block title %}My Account{% endblock %}

{% block main %}
<section class="container">
<h1 class="col-lg-12">My Account</h1>
<div class="col-xs-12 col-md-6 col-md-offset-3">
<div class="row">
<h5 class="text-left font-bold">Are you sure you want to erase all your challenges records on OCD Youth?</h5>
<p>Once erased you cannot recover the record.
</p>
<div class="margin-top-30">
<a class="btn btn-lg btn-outline btn-warning" href="{% url 'delete-users-challenges' %}">Yes, erase my record</a>
</div>
<div class="margin-top-30">
<a href="{% url 'my-account' %}">Cancel and go back to last page</a>
</div>
</div>

</div>
</section>
{% endblock %}
11 changes: 8 additions & 3 deletions ocdaction/ocdaction/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
<nav class="header__nav js-header-nav">
<button class="header__nav-toggle js-nav-toggle"><span class="hidden">Menu</span></button>
<ul class="header__list js-header-list">
<li class="header__item">
<a class="header__link" href="{% url 'challenge-list' %}">Challenges</a>
</li>
{% if user.is_authenticated %}
<li class="header__item">
<a class="header__link" href="{% url 'challenge-list' %}">Challenges</a>
</li>
{% endif %}
<li class="header__item">
<a class="header__link" href="{% url 'learn' %}">Learn</a>
</li>
Expand All @@ -23,6 +25,9 @@
{% if user.is_authenticated %}
<li class="header__item">
<a class="header__link" href="{% url 'challenge-list-archived' %}">Archive</a>
</li>
<li class="header__item">
<a class="header__link" href="{% url 'my-account' %}">My Account</a>
</li>
<li class="header__item">
<a class="header__link" href="{% url 'logout' %}">
Expand Down
30 changes: 30 additions & 0 deletions ocdaction/ocdaction/templates/profiles/my_account.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends "layout.html" %}

{% load static %}
{% block title %}My Account{% endblock %}

{% block main %}
<section class="container">
<h1 class="col-lg-12">My Account</h1>
<div class="col-xs-12 col-md-6 col-md-offset-3">
<div class="row">
<h5 class="text-left font-bold">Erase your record from this platform</h5>
<p>You can erase all your challenges record on OCD Youth while keeping your account.
You can log in with the same email and password.
</p>
<div class="margin-top-30">
<a class="btn btn-lg btn-outline btn-warning" href="{% url 'challenge-erase-my-record' %}">Erase my record</a>
</div>
</div>
<div class="row">
<h5 class="text-left font-bold">Delete your account</h5>
<p>This erases your data and deletes your account. Once clicked you will not be able to log in again.
</p>
<div class="margin-top-30">
<a class="btn btn-lg btn-outline btn-danger" href="{% url 'my-account-delete' %}">I want to delete my account</a>
</div>
</div>

</div>
</section>
{% endblock %}
35 changes: 35 additions & 0 deletions ocdaction/ocdaction/templates/profiles/my_account_confirm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "layout.html" %}

{% load static %}
{% block title %}My Account{% endblock %}

{% block main %}

<section class="container">
<h1 class="col-lg-12">My Account</h1>
<div class="col-xs-12 col-md-6 col-md-offset-3">

{% if deleted_user %}

<div class="row">
<h5 class="text-left font-bold">Your account is now deleted</h5>
<p>You can <a href="{% url 'index' %}">return to the homepage</a>.
</p>
</div>

{% else %}

<div class="row">
<h5 class="text-left font-bold">Your record is now deleted</h5>
<p>You can return to the <a href="{% url 'challenge-list' %}">challenges page</a> to add new challenges.
</p>
</div>

{% endif %}

</div>
</section>



{% endblock %}
24 changes: 24 additions & 0 deletions ocdaction/ocdaction/templates/profiles/my_account_delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "layout.html" %}

{% load static %}
{% block title %}My Account{% endblock %}

{% block main %}
<section class="container">
<h1 class="col-lg-12">My Account</h1>
<div class="col-xs-12 col-md-6 col-md-offset-3">
<div class="row">
<h5 class="text-left font-bold">Are you sure you want to delete your account?</h5>
<p>Once deleted, you cannot recover your account.
</p>
<div class="margin-top-30">
<a class="btn btn-lg btn-outline btn-danger" href="{% url 'delete-user' %}">Yes, delete my account</a>
</div>
<div class="margin-top-30">
<a href="{% url 'my-account' %}">Cancel and go back to last page</a>
</div>
</div>

</div>
</section>
{% endblock %}
2 changes: 1 addition & 1 deletion ocdaction/ocdaction/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
name="index"
),
url(
r'^users/',
r'',
include('profiles.urls')
),
url(
Expand Down
19 changes: 18 additions & 1 deletion ocdaction/profiles/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf.urls import include, url
from django.contrib.auth import views as auth_views

from .views import RegistrationView, RegistrationComplete, ActivationComplete
from .views import *
from .forms import OCDActionUserRegistrationForm


Expand Down Expand Up @@ -50,4 +50,21 @@
),
url(r'^accounts/', include('registration.backends.default.urls')),

url(
r'^my-account/$',
my_account,
name="my-account"
),

url(
r'^my-account-delete/$',
my_account_delete,
name="my-account-delete"
),

url(
r'^delete-user/$',
delete_user,
name="delete-user"
),
]
28 changes: 28 additions & 0 deletions ocdaction/profiles/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from django.views.generic import TemplateView
from django.shortcuts import render, redirect, get_object_or_404

from registration.backends.default import views as registration_views
from profiles.forms import OCDActionUserRegistrationForm
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout

from profiles.models import OCDActionUser
from challenges.views import delete_challenges


class RegistrationComplete(TemplateView):
Expand All @@ -27,3 +33,25 @@ class RegistrationView(registration_views.RegistrationView):

template_name = 'registration/register.html'
form_class = OCDActionUserRegistrationForm

@login_required
def my_account(request):
return render(request, 'profiles/my_account.html')

@login_required
def my_account_delete(request):
return render(request, 'profiles/my_account_delete.html')

@login_required
def delete_user(request):
'''
Delete all a user's challenges and their account
'''

delete_challenges(request.user)

user = OCDActionUser.objects.get(id=request.user.id)
logout(request)
user.delete()

return render(request, 'profiles/my_account_confirm.html', {'deleted_user': True})
11 changes: 11 additions & 0 deletions ocdaction/tests/challenges/test_challenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ def test_challenge_score_form(self):
response = challenge_score_form(request, self.challenge.pk, self.score_card.pk)
assert response.status_code == 200

def test_challenge_erase_my_record(self):
request = self.factory.get(reverse('challenge-erase-my-record'))
request.user = self.user
response = challenge_erase_my_record(request)
assert response.status_code == 200

def test_delete_users_challenges(self):
request = self.factory.get(reverse('delete-users-challenges'))
request.user = self.user
response = delete_users_challenges(request)
assert response.status_code == 200

# Test the forms
@pytest.mark.parametrize(
Expand Down

0 comments on commit 5ac293d

Please sign in to comment.