diff --git a/accounts/migrations/0003_auto_20160612_1421.py b/accounts/migrations/0003_auto_20160612_1421.py new file mode 100644 index 0000000..dd027ae --- /dev/null +++ b/accounts/migrations/0003_auto_20160612_1421.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-06-12 14:21 +from __future__ import unicode_literals + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0002_auto_20160611_1305'), + ] + + operations = [ + migrations.AlterField( + model_name='ponyconfspeaker', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index fd91691..b137d31 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -25,7 +25,7 @@ class PonyConfSpeaker(models.Model): site = models.ForeignKey(Site, on_delete=models.CASCADE) - user = models.ForeignKey(PonyConfUser) + user = models.ForeignKey(User) arrival = models.DateTimeField(blank=True, null=True) departure = models.DateTimeField(blank=True, null=True) transport = models.IntegerField(choices=enum_to_choices(TRANSPORTS), blank=True, null=True) @@ -39,8 +39,7 @@ class PonyConfSpeaker(models.Model): unique_together = ('site', 'user') def __str__(self): - user = self.user.user - return user.get_full_name() or user.username + return self.user.get_full_name() or self.user.username def create_ponyconfuser(sender, instance, created, **kwargs): diff --git a/accounts/templates/accounts/profile.html b/accounts/templates/accounts/profile.html index 4f5391f..5064bae 100644 --- a/accounts/templates/accounts/profile.html +++ b/accounts/templates/accounts/profile.html @@ -22,6 +22,7 @@ {% endfor %} {% buttons layout="horizontal" %} + Change password {% endbuttons %} diff --git a/accounts/templates/registration/logged_out.html b/accounts/templates/registration/logged_out.html new file mode 100644 index 0000000..89a935c --- /dev/null +++ b/accounts/templates/registration/logged_out.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} + +{% load bootstrap3 %} + +{% block content %} + + + +
+
+
+

You are not logged in anymore. Login again ?

+
+
+
+ +{% endblock %} diff --git a/accounts/templates/registration/login.html b/accounts/templates/registration/login.html new file mode 100644 index 0000000..a2b5acc --- /dev/null +++ b/accounts/templates/registration/login.html @@ -0,0 +1,29 @@ +{% extends 'base.html' %} + +{% load bootstrap3 %} + +{% block content %} + + + +
+
+
+
+ {% bootstrap_form form %} + {% csrf_token %} +
+ + Reset your password + Cancel +
+
+
+
+
+ +{% endblock %} diff --git a/accounts/templates/accounts/login.html b/accounts/templates/registration/password_change_form.html similarity index 84% rename from accounts/templates/accounts/login.html rename to accounts/templates/registration/password_change_form.html index 6f2ab0e..58ba91f 100644 --- a/accounts/templates/accounts/login.html +++ b/accounts/templates/registration/password_change_form.html @@ -6,7 +6,7 @@ @@ -18,7 +18,7 @@ {% csrf_token %}
- + Cancel
diff --git a/accounts/templates/registration/password_reset_form.html b/accounts/templates/registration/password_reset_form.html new file mode 100644 index 0000000..1eaafd1 --- /dev/null +++ b/accounts/templates/registration/password_reset_form.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} + +{% load bootstrap3 %} + +{% block content %} + + + +
+
+
+
+ {% bootstrap_form form %} + {% csrf_token %} +
+ + Cancel +
+
+
+
+
+ +{% endblock %} diff --git a/accounts/tests.py b/accounts/tests.py index 62b5ec3..8c71bc8 100644 --- a/accounts/tests.py +++ b/accounts/tests.py @@ -1,9 +1,8 @@ -from django.test import TestCase from django.contrib.auth.models import User from django.core.urlresolvers import reverse +from django.test import TestCase -from .models import PonyConfSpeaker, PonyConfUser - +from .models import PonyConfUser ROOT_URL = 'accounts' @@ -20,10 +19,6 @@ class AccountTests(TestCase): # VIEWS - def test_password(self): - self.client.login(username='a', password='a') - self.assertEqual(self.client.get(reverse('password')).status_code, 200) - def test_profile(self): # User b wants to update its username, email and biography user = User.objects.get(username='b') @@ -33,10 +28,10 @@ class AccountTests(TestCase): self.client.login(username='b', password='b') # He tries with an invalid address - r = self.client.post(reverse('profile'), {'email': 'bnewdomain.com', 'username': 'z', 'biography': 'tester'}) + self.client.post(reverse('profile'), {'email': 'bnewdomain.com', 'username': 'z', 'biography': 'tester'}) self.assertEqual(User.objects.filter(username='z').count(), 0) - r = self.client.post(reverse('profile'), {'email': 'b@newdomain.com', 'username': 'z', 'biography': 'tester'}) + self.client.post(reverse('profile'), {'email': 'b@newdomain.com', 'username': 'z', 'biography': 'tester'}) user = User.objects.get(username='z') self.assertEqual(user.email, 'b@newdomain.com') diff --git a/accounts/urls.py b/accounts/urls.py index 2062cfe..5613344 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -1,11 +1,8 @@ -from django.conf.urls import url -from django.contrib.auth import views as auth_views +from django.conf.urls import include, url -from accounts import views +from .views import profile urlpatterns = [ - url(r'^login/$', auth_views.login, {'template_name': 'accounts/login.html'}, name='login'), - url(r'^logout/$', auth_views.logout, {'next_page': '/'}, name='logout'), - url(r'^profile$', views.profile, name='profile'), - url(r'^password$', views.password, name='password'), + url(r'^profile$', profile, name='profile'), + url(r'', include('django.contrib.auth.urls')), ] diff --git a/accounts/views.py b/accounts/views.py index e9e09f3..ee114f5 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,16 +1,10 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required -from django.contrib.auth.views import password_change from django.shortcuts import render from .forms import PonyConfUserForm, ProfileForm -@login_required -def password(request): - return password_change(request, post_change_redirect='profile') - - @login_required def profile(request): diff --git a/ponyconf/settings.py b/ponyconf/settings.py index da29971..bd1d33f 100644 --- a/ponyconf/settings.py +++ b/ponyconf/settings.py @@ -31,8 +31,9 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', + 'accounts', 'registration', + 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', @@ -44,7 +45,6 @@ INSTALLED_APPS = [ 'bootstrap3', 'ponyconf', - 'accounts', 'proposals', ] @@ -173,3 +173,4 @@ BOOTSTRAP3 = { } AUTHENTICATION_BACKENDS = ['yeouia.backends.YummyEmailOrUsernameInsensitiveAuth'] +LOGOUT_REDIRECT_URL = 'home' diff --git a/proposals/migrations/0005_auto_20160612_1421.py b/proposals/migrations/0005_auto_20160612_1421.py new file mode 100644 index 0000000..24858f6 --- /dev/null +++ b/proposals/migrations/0005_auto_20160612_1421.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-06-12 14:21 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('proposals', '0004_auto_20160611_1305'), + ] + + operations = [ + migrations.RenameField( + model_name='speach', + old_name='user', + new_name='speaker', + ), + migrations.AlterUniqueTogether( + name='speach', + unique_together=set([('speaker', 'talk'), ('order', 'talk')]), + ), + ] diff --git a/proposals/models.py b/proposals/models.py index e0f8cbd..af7490e 100644 --- a/proposals/models.py +++ b/proposals/models.py @@ -43,19 +43,19 @@ class Speach(models.Model): SPEAKER_NO = tuple((i, str(i)) for i in range(1, 8)) - user = models.ForeignKey(PonyConfSpeaker, on_delete=models.CASCADE) + speaker = models.ForeignKey(PonyConfSpeaker, on_delete=models.CASCADE) talk = models.ForeignKey(Talk, on_delete=models.CASCADE) order = models.IntegerField(choices=SPEAKER_NO) class Meta: ordering = ['talk', 'order'] unique_together = ( - ('user', 'talk'), + ('speaker', 'talk'), ('order', 'talk'), ) def __str__(self): - return '%s speaking at %s in position %d' % (self.user, self.talk, self.order) + return '%s speaking at %s in position %d' % (self.speaker, self.talk, self.order) def username(self): - return self.user.user.user.username + return self.speaker.user.username diff --git a/proposals/templates/proposals/talk_details.html b/proposals/templates/proposals/talk_details.html index 66344ac..c42e2a4 100644 --- a/proposals/templates/proposals/talk_details.html +++ b/proposals/templates/proposals/talk_details.html @@ -16,7 +16,7 @@