small fixes #21
6 changed files with 89 additions and 36 deletions
|
@ -79,6 +79,8 @@ MEDIA_URL = "/media/"
|
||||||
LOGIN_REDIRECT_URL = 'shared:home'
|
LOGIN_REDIRECT_URL = 'shared:home'
|
||||||
LOGOUT_REDIRECT_URL = 'shared:home'
|
LOGOUT_REDIRECT_URL = 'shared:home'
|
||||||
|
|
||||||
|
AUTH_USER_MODEL = "users.User"
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
|
21
event/migrations/0002_auto_20170723_1419.py
Normal file
21
event/migrations/0002_auto_20170723_1419.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.3 on 2017-07-23 14:19
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('event', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='activity',
|
||||||
|
name='parent',
|
||||||
|
field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='event.ActivityTemplate'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,10 +1,12 @@
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth import get_user_model
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from communication.models import SubscriptionMixin
|
from communication.models import SubscriptionMixin
|
||||||
|
|
||||||
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class Event(SubscriptionMixin, models.Model):
|
class Event(SubscriptionMixin, models.Model):
|
||||||
title = models.CharField(
|
title = models.CharField(
|
||||||
|
@ -164,6 +166,7 @@ class Activity(AbstractActivityTemplate):
|
||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
ActivityTemplate,
|
ActivityTemplate,
|
||||||
related_name="children",
|
related_name="children",
|
||||||
|
blank=True,
|
||||||
)
|
)
|
||||||
staff = models.ManyToManyField(
|
staff = models.ManyToManyField(
|
||||||
User,
|
User,
|
||||||
|
|
46
users/migrations/0001_initial.py
Normal file
46
users/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.3 on 2017-07-23 14:14
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import django.contrib.auth.models
|
||||||
|
import django.contrib.auth.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('auth', '0008_alter_user_username_max_length'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='User',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||||
|
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||||
|
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||||
|
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
|
||||||
|
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
|
||||||
|
('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')),
|
||||||
|
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
|
||||||
|
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
||||||
|
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||||
|
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
||||||
|
('phone', models.CharField(blank=True, max_length=20, verbose_name='numéro de téléphone')),
|
||||||
|
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
|
||||||
|
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'utilisateur',
|
||||||
|
'verbose_name_plural': 'utilisateurs',
|
||||||
|
},
|
||||||
|
managers=[
|
||||||
|
('objects', django.contrib.auth.models.UserManager()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,2 +1,17 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import AbstractUser, UserManager
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
|
class User(AbstractUser):
|
||||||
|
phone = models.CharField(
|
||||||
|
_('numéro de téléphone'),
|
||||||
|
max_length=20,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
objects = UserManager()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _("utilisateur")
|
||||||
|
verbose_name_plural = _("utilisateurs")
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
from django.test import TestCase, Client
|
|
||||||
from django.conf import settings
|
|
||||||
from django.contrib.auth.models import User
|
|
||||||
|
|
||||||
|
|
||||||
class TestUserCreation(TestCase):
|
|
||||||
def test_create_view(self):
|
|
||||||
"""Create a user using the user creation form"""
|
|
||||||
user_data = {
|
|
||||||
"username": "MrsFoobar",
|
|
||||||
"first_name": "Baz",
|
|
||||||
"last_name": "Foobar",
|
|
||||||
"email": "baz@foobar.net",
|
|
||||||
}
|
|
||||||
|
|
||||||
data = user_data.copy()
|
|
||||||
data["password1"] = "4zwY5jdI"
|
|
||||||
data["password2"] = "4zwY5jdI"
|
|
||||||
data["key"] = settings.CREATE_USER_KEY
|
|
||||||
|
|
||||||
client = Client()
|
|
||||||
resp = client.post("/user/create/", data)
|
|
||||||
|
|
||||||
# The user redirection means successful form validation
|
|
||||||
self.assertRedirects(resp, "/")
|
|
||||||
|
|
||||||
# The user should now exist
|
|
||||||
user = (
|
|
||||||
User.objects
|
|
||||||
.filter(username=data["username"])
|
|
||||||
.values(*user_data.keys())
|
|
||||||
.get()
|
|
||||||
)
|
|
||||||
self.assertEqual(user_data, user)
|
|
Loading…
Reference in a new issue