adapt migrations and tests

This commit is contained in:
Ludovic Stephan 2017-07-18 15:37:13 +02:00
parent 4e8873226f
commit 270e31f12b
6 changed files with 92 additions and 37 deletions

View file

@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-18 13:17
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('contenttypes', '0002_remove_content_type_name'),
('auth', '0008_alter_user_username_max_length'),
]
operations = [
migrations.CreateModel(
name='GroupSubscription',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.PositiveIntegerField()),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.Group')),
],
options={
'verbose_name': 'souscription en groupe',
},
),
migrations.CreateModel(
name='UserSubscription',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('object_id', models.PositiveIntegerField()),
('is_unsub', models.BooleanField(default=False, verbose_name='désinscription')),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'souscription utilisateur',
},
),
]

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-21 20:14 # Generated by Django 1.11.3 on 2017-07-18 13:17
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
@ -19,9 +19,9 @@ class Migration(migrations.Migration):
name='AbstractEquipment', name='AbstractEquipment',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, verbose_name='Nom du matériel')), ('name', models.CharField(max_length=200, verbose_name='nom du matériel')),
('stock', models.PositiveSmallIntegerField(verbose_name='Quantité disponible')), ('stock', models.PositiveSmallIntegerField(verbose_name='quantité disponible')),
('description', models.TextField(verbose_name='Description')), ('description', models.TextField(verbose_name='description')),
], ],
options={ options={
'verbose_name': 'matériel abstrait', 'verbose_name': 'matériel abstrait',
@ -32,8 +32,8 @@ class Migration(migrations.Migration):
name='EquipmentAttribution', name='EquipmentAttribution',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount', models.PositiveSmallIntegerField(verbose_name='Quantité attribuée')), ('amount', models.PositiveSmallIntegerField(verbose_name='quantité attribuée')),
('remarks', models.TextField(verbose_name="Remarques concernant l'attribution")), ('remarks', models.TextField(verbose_name="remarques concernant l'attribution")),
('activity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='event.Activity')), ('activity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='event.Activity')),
], ],
options={ options={
@ -45,7 +45,8 @@ class Migration(migrations.Migration):
name='EquipmentRemark', name='EquipmentRemark',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('remark', models.TextField(verbose_name='Remarque sur le matériel')), ('remark', models.TextField(verbose_name='remarque sur le matériel')),
('amount', models.PositiveSmallIntegerField(verbose_name='quantité concernée')),
('is_broken', models.BooleanField()), ('is_broken', models.BooleanField()),
('is_lost', models.BooleanField()), ('is_lost', models.BooleanField()),
], ],

View file

@ -12,7 +12,7 @@ urlpatterns = [
url(r'^', include('shared.urls')), url(r'^', include('shared.urls')),
] ]
if settings.DEBUG: if 'debug_toolbar' in settings.INSTALLED_APPS:
import debug_toolbar import debug_toolbar
urlpatterns += [ urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)), url(r'^__debug__/', include(debug_toolbar.urls)),

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-21 20:14 # Generated by Django 1.11.3 on 2017-07-18 13:17
from __future__ import unicode_literals from __future__ import unicode_literals
from django.conf import settings from django.conf import settings
@ -21,68 +21,71 @@ class Migration(migrations.Migration):
name='ActivityTag', name='ActivityTag',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, verbose_name='Nom du tag')), ('name', models.CharField(max_length=200, verbose_name='nom du tag')),
('is_public', models.BooleanField(help_text="Sert à faire une distinction dans l'affichage selon que cela soit destiné au public ou à l'équipe organisatrice")), ('is_public', models.BooleanField(help_text="Sert à faire une distinction dans l'affichage selon que cela soit destiné au public ou à l'équipe organisatrice")),
('color', models.CharField(help_text='Rentrer une couleur en hexadécimal', max_length=7, validators=[django.core.validators.RegexValidator(message="La chaîne de caractère rentrée n'est pasune couleur en hexadécimal.", regex='^#(?:[0-9a-fA-F]{3}){1,2}$')], verbose_name='Couleur')), ('color', models.CharField(help_text='Rentrer une couleur en hexadécimal', max_length=7, validators=[django.core.validators.RegexValidator(message="La chaîne de caractère rentrée n'est pas une couleur en hexadécimal.", regex='^#(?:[0-9a-fA-F]{3}){1,2}$')], verbose_name='couleur')),
], ],
options={ options={
'verbose_name': 'tag',
'verbose_name_plural': 'tags', 'verbose_name_plural': 'tags',
'verbose_name': 'tag',
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='ActivityTemplate', name='ActivityTemplate',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(blank=True, max_length=200, null=True, verbose_name="Nom de l'activité")), ('title', models.CharField(blank=True, max_length=200, null=True, verbose_name="nom de l'activité")),
('is_public', models.NullBooleanField()), ('is_public', models.NullBooleanField()),
('has_perm', models.NullBooleanField()), ('has_perm', models.NullBooleanField()),
('min_perm', models.PositiveSmallIntegerField(blank=True, null=True, verbose_name='Nombre minimum de permanents')), ('min_perm', models.PositiveSmallIntegerField(blank=True, null=True, verbose_name='nombre minimum de permanents')),
('max_perm', models.PositiveSmallIntegerField(blank=True, null=True, verbose_name='Nombre maximum de permanents')), ('max_perm', models.PositiveSmallIntegerField(blank=True, null=True, verbose_name='nombre maximum de permanents')),
('description', models.TextField(blank=True, help_text='Public, Visible par tout le monde.', null=True, verbose_name='Description')), ('description', models.TextField(blank=True, help_text='Public, Visible par tout le monde.', null=True, verbose_name='description')),
('remarks', models.TextField(blank=True, help_text='Visible uniquement par les organisateurs', null=True, verbose_name='Remarques')), ('remarks', models.TextField(blank=True, help_text='Visible uniquement par les organisateurs', null=True, verbose_name='remarques')),
], ],
options={ options={
'verbose_name': 'template activité',
'verbose_name_plural': 'templates activité', 'verbose_name_plural': 'templates activité',
'verbose_name': 'template activité',
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Event', name='Event',
fields=[ fields=[
('title', models.CharField(max_length=200, verbose_name="Nom de l'évènement")), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(help_text="Seulement des lettres, des chiffres oules caractères '_' ou '-'.", primary_key=True, serialize=False, unique=True, verbose_name='Identificateur')), ('title', models.CharField(max_length=200, verbose_name="nom de l'évènement")),
('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='Date de création')), ('slug', models.SlugField(help_text="Seulement des lettres, des chiffres oules caractères '_' ou '-'.", unique=True, verbose_name='identificateur')),
('description', models.TextField(verbose_name='Description')), ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='date de création')),
('beginning_date', models.DateTimeField(verbose_name='Date de début')), ('description', models.TextField(verbose_name='description')),
('ending_date', models.DateTimeField(verbose_name='Date de fin')), ('beginning_date', models.DateTimeField(verbose_name='date de début')),
('ending_date', models.DateTimeField(blank=True, null=True, verbose_name='date de fin')),
('created_by', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='created_events', to=settings.AUTH_USER_MODEL)), ('created_by', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='created_events', to=settings.AUTH_USER_MODEL)),
], ],
options={ options={
'verbose_name': 'évènement',
'verbose_name_plural': 'évènements', 'verbose_name_plural': 'évènements',
'verbose_name': 'évènement',
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Place', name='Place',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, verbose_name='Nom du lieu')), ('name', models.CharField(max_length=200, verbose_name='nom du lieu')),
('description', models.TextField(blank=True)), ('description', models.TextField(blank=True)),
], ],
options={ options={
'verbose_name': 'lieu',
'verbose_name_plural': 'lieux', 'verbose_name_plural': 'lieux',
'verbose_name': 'lieu',
}, },
), ),
migrations.CreateModel( migrations.CreateModel(
name='Activity', name='Activity',
fields=[ fields=[
('activitytemplate_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='event.ActivityTemplate')), ('activitytemplate_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='event.ActivityTemplate')),
('beginning', models.DateTimeField(verbose_name='heure de début')),
('end', models.DateTimeField(verbose_name='heure de fin')),
], ],
options={ options={
'verbose_name': 'activité',
'verbose_name_plural': 'activités', 'verbose_name_plural': 'activités',
'verbose_name': 'activité',
}, },
bases=('event.activitytemplate',), bases=('event.activitytemplate',),
), ),

View file

@ -44,51 +44,56 @@ class ActivityInheritanceTest(TestCase):
self.template_act = ActivityTemplate.objects.create() self.template_act = ActivityTemplate.objects.create()
self.real_act = Activity.objects.create( self.real_act = Activity.objects.create(
parent=self.template_act, parent=self.template_act,
beginning=timezone.now()
+ timedelta(days=30),
end=timezone.now()
+ timedelta(days=30)
+ timedelta(hours=2),
) )
def test_inherites_title(self): def test_inherits_title(self):
self.template_act.title = "parent" self.template_act.title = "parent"
self.assertEqual(self.real_act.get_herited('title'), "parent") self.assertEqual(self.real_act.get_herited('title'), "parent")
self.real_act.title = "enfant" self.real_act.title = "enfant"
self.assertEqual(self.real_act.get_herited('title'), "enfant") self.assertEqual(self.real_act.get_herited('title'), "enfant")
def test_inherites_description(self): def test_inherits_description(self):
self.template_act.description = "parent" self.template_act.description = "parent"
self.assertEqual(self.real_act.get_herited('description'), "parent") self.assertEqual(self.real_act.get_herited('description'), "parent")
self.real_act.description = "enfant" self.real_act.description = "enfant"
self.assertEqual(self.real_act.get_herited('description'), "enfant") self.assertEqual(self.real_act.get_herited('description'), "enfant")
def test_inherites_remarks(self): def test_inherits_remarks(self):
self.template_act.remarks = "parent" self.template_act.remarks = "parent"
self.assertEqual(self.real_act.get_herited('remarks'), "parent") self.assertEqual(self.real_act.get_herited('remarks'), "parent")
self.real_act.remarks = "enfant" self.real_act.remarks = "enfant"
self.assertEqual(self.real_act.get_herited('remarks'), "enfant") self.assertEqual(self.real_act.get_herited('remarks'), "enfant")
def test_inherites_is_public(self): def test_inherits_is_public(self):
self.template_act.is_public = True self.template_act.is_public = True
self.assertEqual(self.real_act.get_herited('is_public'), True) self.assertEqual(self.real_act.get_herited('is_public'), True)
self.real_act.is_public = False self.real_act.is_public = False
self.assertEqual(self.real_act.get_herited('is_public'), False) self.assertEqual(self.real_act.get_herited('is_public'), False)
def test_inherites_has_perm(self): def test_inherits_has_perm(self):
self.template_act.has_perm = True self.template_act.has_perm = True
self.assertEqual(self.real_act.get_herited('has_perm'), True) self.assertEqual(self.real_act.get_herited('has_perm'), True)
self.real_act.has_perm = False self.real_act.has_perm = False
self.assertEqual(self.real_act.get_herited('has_perm'), False) self.assertEqual(self.real_act.get_herited('has_perm'), False)
def test_inherites_min_perm(self): def test_inherits_min_perm(self):
self.template_act.min_perm = 42 self.template_act.min_perm = 42
self.assertEqual(self.real_act.get_herited('min_perm'), 42) self.assertEqual(self.real_act.get_herited('min_perm'), 42)
self.real_act.min_perm = 1 self.real_act.min_perm = 1
self.assertEqual(self.real_act.get_herited('min_perm'), 1) self.assertEqual(self.real_act.get_herited('min_perm'), 1)
def test_inherites_max_perm(self): def test_inherits_max_perm(self):
self.template_act.max_perm = 42 self.template_act.max_perm = 42
self.assertEqual(self.real_act.get_herited('max_perm'), 42) self.assertEqual(self.real_act.get_herited('max_perm'), 42)
self.real_act.max_perm = 1 self.real_act.max_perm = 1
self.assertEqual(self.real_act.get_herited('max_perm'), 1) self.assertEqual(self.real_act.get_herited('max_perm'), 1)
def test_inherites_place(self): def test_inherits_place(self):
self.template_act.place.add(self.loge) self.template_act.place.add(self.loge)
self.assertEqual( self.assertEqual(
self.real_act.get_herited('place').get(), self.real_act.get_herited('place').get(),
@ -100,7 +105,7 @@ class ActivityInheritanceTest(TestCase):
self.aqua self.aqua
) )
def test_inherites_tags(self): def test_inherits_tags(self):
self.template_act.tags.add(self.tag_foo) self.template_act.tags.add(self.tag_foo)
self.assertEqual( self.assertEqual(
self.real_act.get_herited('tags').get(), self.real_act.get_herited('tags').get(),