-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
debcf57
commit d4a4c31
Showing
1,367 changed files
with
45,110 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountsConfig(AppConfig): | ||
name = 'accounts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.contrib.auth.models import User | ||
from django.forms import ModelForm | ||
|
||
|
||
class UserCreateForm(UserCreationForm): | ||
class Meta: | ||
fields = ("username", "email", "password1", "password2") | ||
model = User | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.fields["username"].label = "Username" | ||
self.fields["email"].label = "Email Address" | ||
self.fields['email'].required = True | ||
|
||
|
||
class DeactivateUserForm(ModelForm): | ||
class Meta: | ||
model = User | ||
fields = ['is_active'] | ||
|
||
def clean_is_active(self): | ||
# Reverses true/false for your form prior to validation | ||
# | ||
# You can also raise a ValidationError here if you receive | ||
# a value you don't want, to prevent the form's is_valid | ||
# method from return true if, say, the user hasn't chosen | ||
# to deactivate their account | ||
is_active = not(self.cleaned_data["is_active"]) | ||
return is_active |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends 'layout.html' %} | ||
|
||
{% block header_title %}Delete Account{% endblock %} | ||
|
||
{% block body_content %} | ||
<form action="" method="POST"> | ||
{% csrf_token %} | ||
<p>Are you sure you want to delete your account?</p> | ||
<input type="submit" class="btn" value="Confirm" /> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends 'layout.html' %} | ||
|
||
{% block head_extra %} | ||
<link rel="stylesheet" href="/static/style.css"/> | ||
{% endblock %} | ||
|
||
{% load bootstrap3 %} | ||
|
||
{% block title_tag %}Login | {{ block.super }}{% endblock %} | ||
|
||
{% block body_content %} | ||
|
||
<div class="container"> | ||
<form method="post" class="form"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
{% buttons %} | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
{% endbuttons %} | ||
</form> | ||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends 'layout.html' %} | ||
|
||
{% block header_title %}Profile{% endblock %} | ||
|
||
{% block body_content %} | ||
<a href="{% url 'accounts:delete' %}">Delete account</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends 'layout.html' %} | ||
|
||
{% load bootstrap3 %} | ||
|
||
{% block title_tag %}Sign Up | {{ block.super }}{% endblock %} | ||
|
||
{% block body_content %} | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
{% buttons %} | ||
<button type="submit" class="btn btn-primary">Sign Up</button> | ||
{% endbuttons %} | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from django.contrib.auth.models import User | ||
from django.core.exceptions import ValidationError | ||
from django.test import TestCase | ||
|
||
from . import forms | ||
|
||
|
||
class UserTestCase(TestCase): | ||
def test_signup_form_success(self): | ||
"""Successfully signup with correct values""" | ||
form_data = { | ||
'username': 'testuser', | ||
'email': 'test@email.com', | ||
'password1': 'testpassword', | ||
'password2': 'testpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertTrue(form.is_valid()) | ||
|
||
def test_signup_form_bad_username_1(self): | ||
"""Fail to signup because of no username""" | ||
form_data = { | ||
'username': '', | ||
'email': 'test@email.com', | ||
'password1': 'testpassword', | ||
'password2': 'testpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_signup_form_bad_username_2(self): | ||
"""Fail to signup because of a username that is over 255 characters""" | ||
form_data = { | ||
'username': 'lkjahsdfkljhqwiuehflakjsdhflkjhsadlfiuhqoeiuryqoweiurhlkjsdlakjfnlkjsadhflkjahsdfkljhqwiuehflakjsdhflkjhsadlfiuhqoeiuryqoweiurhlkjsdlakjfnlkjsadhflkjahsdfkljhqwiuehflakjsdhflkjhsadlfiuhqoeiuryqoweiurhlkjsdlakjfnlkjsadhflkjahsdfkljhqwiuehflakjsdhflkjhsadlfiuhqoeiuryqoweiurhlkjsdlakjfnlkjsadhf', | ||
'email': 'test@email.com', | ||
'password1': 'testpassword', | ||
'password2': 'testpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_signup_form_bad_email_1(self): | ||
"""Fail to signup because of a bad email""" | ||
form_data = { | ||
'username': 'testuser', | ||
'email': 'test', | ||
'password1': 'testpassword', | ||
'password2': 'testpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_signup_form_bad_email_2(self): | ||
"""Fail to signup because of a bad email""" | ||
form_data = { | ||
'username': 'testuser', | ||
'email': 'test@email', | ||
'password1': 'testpassword', | ||
'password2': 'testpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_signup_form_bad_email_3(self): | ||
"""Fail to signup because of no email""" | ||
form_data = { | ||
'username': 'testuser', | ||
'email': '', | ||
'password1': 'testpassword', | ||
'password2': 'testpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertFalse(form.is_valid()) | ||
|
||
def test_signup_form_password_mismatch(self): | ||
"""Fail to signup because passwords don't match""" | ||
form_data = { | ||
'username': 'testuser', | ||
'email': 'test@email.com', | ||
'password1': 'testpassword', | ||
'password2': 'badpassword', | ||
} | ||
form = forms.UserCreateForm(data=form_data) | ||
self.assertFalse(form.is_valid()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.conf.urls import url | ||
|
||
from . import views | ||
|
||
app_name = 'accounts' | ||
urlpatterns = [ | ||
url(r'profile/$', views.ProfileView.as_view(), name='profile'), | ||
url(r'login/$', views.LoginView.as_view(), name='login'), | ||
url(r'logout/$', views.LogoutView.as_view(), name='logout'), | ||
url(r'signup/$', views.Signup.as_view(), name='signup'), | ||
url(r'delete/$', views.deactivate_user_view, name='delete'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from django.contrib import messages | ||
from django.contrib.auth import login, logout | ||
from django.contrib.auth.forms import AuthenticationForm | ||
from django.contrib.auth.models import User | ||
from django.core.urlresolvers import reverse_lazy | ||
from django.http import HttpResponseRedirect | ||
from django.shortcuts import render | ||
from django.urls import reverse | ||
from django.views import generic, View | ||
from django.views.generic import TemplateView | ||
|
||
from . import forms | ||
|
||
|
||
class ProfileView(TemplateView): | ||
template_name = 'accounts/profile.html' | ||
|
||
|
||
class LoginView(generic.FormView): | ||
form_class = AuthenticationForm | ||
success_url = reverse_lazy('home') | ||
template_name = 'accounts/login.html' | ||
|
||
def get_form(self, form_class=None): | ||
if form_class is None: | ||
form_class = self.get_form_class() | ||
return form_class(self.request, **self.get_form_kwargs()) | ||
|
||
def form_valid(self, form): | ||
login(self.request, form.get_user()) | ||
return super().form_valid(form) | ||
|
||
|
||
class LogoutView(generic.RedirectView): | ||
url = reverse_lazy('home') | ||
|
||
def get(self, request, *args, **kwargs): | ||
logout(request) | ||
return super().get(request, *args, **kwargs) | ||
|
||
|
||
class Signup(generic.CreateView): | ||
form_class = forms.UserCreateForm | ||
success_url = reverse_lazy("accounts:login") | ||
template_name = "accounts/signup.html" | ||
|
||
|
||
def deactivate_user_view(request): | ||
user = User.objects.get(pk=request.user.pk) | ||
form = forms.DeactivateUserForm(instance=user) | ||
if request.user.is_authenticated() and request.user.id == user.id: | ||
if request.method == "POST": | ||
form = forms.DeactivateUserForm(request.POST, instance=user) | ||
if form.is_valid(): | ||
deactivate_user = form.save(commit=False) | ||
user.is_active = False | ||
deactivate_user.save() | ||
messages.add_message(request, messages.SUCCESS, "Account deleted!") | ||
return HttpResponseRedirect(reverse_lazy('accounts:logout')) | ||
return render(request, "accounts/account_confirm_delete.html", { | ||
"form": form, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
.rte-autocomplete{ | ||
position: absolute; | ||
top: 0px; | ||
left: 0px; | ||
display: block; | ||
z-index: 1000; | ||
float: left; | ||
min-width: 160px; | ||
padding: 5px 0; | ||
margin: 2px 0 0; | ||
list-style: none; | ||
background-color: #fff; | ||
border: 1px solid #ccc; | ||
border: 1px solid rgba(0,0,0,0.2); | ||
-webkit-border-radius: 6px; | ||
-moz-border-radius: 6px; | ||
border-radius: 6px; | ||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,0.2); | ||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,0.2); | ||
box-shadow: 0 5px 10px rgba(0,0,0,0.2); | ||
-webkit-background-clip: padding-box; | ||
-moz-background-clip: padding; | ||
background-clip: padding-box; | ||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; | ||
font-size: 14px; | ||
} | ||
|
||
.rte-autocomplete:before { | ||
content: ''; | ||
display: inline-block; | ||
border-left: 7px solid transparent; | ||
border-right: 7px solid transparent; | ||
border-bottom: 7px solid #ccc; | ||
border-bottom-color: rgba(0, 0, 0, 0.2); | ||
position: absolute; | ||
top: -7px; | ||
left: 9px; | ||
} | ||
|
||
.rte-autocomplete:after { | ||
content: ''; | ||
display: inline-block; | ||
border-left: 6px solid transparent; | ||
border-right: 6px solid transparent; | ||
border-bottom: 6px solid white; | ||
position: absolute; | ||
top: -6px; | ||
left: 10px; | ||
} | ||
|
||
.rte-autocomplete > li.loading { | ||
background: url("http://www.ajaxload.info/cache/FF/FF/FF/00/00/00/1-0.gif") center no-repeat; | ||
height: 16px; | ||
} | ||
|
||
.rte-autocomplete > li > a { | ||
display: block; | ||
padding: 3px 20px; | ||
clear: both; | ||
font-weight: normal; | ||
line-height: 20px; | ||
color: #333; | ||
white-space: nowrap; | ||
text-decoration: none; | ||
} | ||
|
||
.rte-autocomplete >li > a:hover, .rte-autocomplete > li > a:focus, .rte-autocomplete:hover > a, .rte-autocomplete:focus > a { | ||
color: #fff; | ||
text-decoration: none; | ||
background-color: #0081c2; | ||
background-image: -moz-linear-gradient(top,#08c,#0077b3); | ||
background-image: -webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3)); | ||
background-image: -webkit-linear-gradient(top,#08c,#0077b3); | ||
background-image: -o-linear-gradient(top,#08c,#0077b3); | ||
background-image: linear-gradient(to bottom,#08c,#0077b3); | ||
background-repeat: repeat-x; | ||
filter: progid:DXImageTransform.Microsoft; | ||
} | ||
|
||
.rte-autocomplete >.active > a, .rte-autocomplete > .active > a:hover, .rte-autocomplete > .active > a:focus { | ||
color: #fff; | ||
text-decoration: none; | ||
background-color: #0081c2; | ||
background-image: -moz-linear-gradient(top,#08c,#0077b3); | ||
background-image: -webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3)); | ||
background-image: -webkit-linear-gradient(top,#08c,#0077b3); | ||
background-image: -o-linear-gradient(top,#08c,#0077b3); | ||
background-image: linear-gradient(to bottom,#08c,#0077b3); | ||
background-repeat: repeat-x; | ||
outline: 0; | ||
filter: progid:DXImageTransform.Microsoft; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
body { | ||
/*min-height: 2000px;*/ | ||
padding-top: 50px; | ||
background: url("../img/body_bg.png") no-repeat center center fixed; | ||
-webkit-background-size: cover; | ||
-moz-background-size: cover; | ||
-o-background-size: cover; | ||
background-size: cover; | ||
margin-bottom: 150px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
body { | ||
/*min-height: 2000px;*/ | ||
padding-top: 50px; | ||
background: url("../img/banner.png") no-repeat center center fixed; | ||
-webkit-background-size: cover; | ||
-moz-background-size: cover; | ||
-o-background-size: cover; | ||
background-size: cover; | ||
/*margin-bottom: 150px !important;*/ | ||
} | ||
#logo_wrapper { | ||
margin: 0 auto; | ||
} | ||
.cover { | ||
padding-top: 0; | ||
} |
Oops, something went wrong.