From 270e31f12be4a21dbc68a5e5c974105d7d95c0a0 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 18 Jul 2017 15:37:13 +0200 Subject: [PATCH] adapt migrations and tests --- communication/migrations/0001_initial.py | 46 ++++++++++++++++++++++++ equipment/migrations/0001_initial.py | 15 ++++---- evenementiel/urls.py | 2 +- event/migrations/0001_initial.py | 43 +++++++++++----------- event/tests.py | 23 +++++++----- shared/migrations/__init__.py | 0 6 files changed, 92 insertions(+), 37 deletions(-) create mode 100644 communication/migrations/0001_initial.py delete mode 100644 shared/migrations/__init__.py diff --git a/communication/migrations/0001_initial.py b/communication/migrations/0001_initial.py new file mode 100644 index 0000000..c4e91f1 --- /dev/null +++ b/communication/migrations/0001_initial.py @@ -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', + }, + ), + ] diff --git a/equipment/migrations/0001_initial.py b/equipment/migrations/0001_initial.py index ccc9e91..eea7be7 100644 --- a/equipment/migrations/0001_initial.py +++ b/equipment/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- 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 django.db import migrations, models @@ -19,9 +19,9 @@ class Migration(migrations.Migration): name='AbstractEquipment', fields=[ ('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')), - ('stock', models.PositiveSmallIntegerField(verbose_name='Quantité disponible')), - ('description', models.TextField(verbose_name='Description')), + ('name', models.CharField(max_length=200, verbose_name='nom du matériel')), + ('stock', models.PositiveSmallIntegerField(verbose_name='quantité disponible')), + ('description', models.TextField(verbose_name='description')), ], options={ 'verbose_name': 'matériel abstrait', @@ -32,8 +32,8 @@ class Migration(migrations.Migration): name='EquipmentAttribution', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('amount', models.PositiveSmallIntegerField(verbose_name='Quantité attribuée')), - ('remarks', models.TextField(verbose_name="Remarques concernant l'attribution")), + ('amount', models.PositiveSmallIntegerField(verbose_name='quantité attribuée')), + ('remarks', models.TextField(verbose_name="remarques concernant l'attribution")), ('activity', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='event.Activity')), ], options={ @@ -45,7 +45,8 @@ class Migration(migrations.Migration): name='EquipmentRemark', fields=[ ('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_lost', models.BooleanField()), ], diff --git a/evenementiel/urls.py b/evenementiel/urls.py index d83241d..e002332 100644 --- a/evenementiel/urls.py +++ b/evenementiel/urls.py @@ -12,7 +12,7 @@ urlpatterns = [ url(r'^', include('shared.urls')), ] -if settings.DEBUG: +if 'debug_toolbar' in settings.INSTALLED_APPS: import debug_toolbar urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), diff --git a/event/migrations/0001_initial.py b/event/migrations/0001_initial.py index 067d32d..d5343fb 100644 --- a/event/migrations/0001_initial.py +++ b/event/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- 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 django.conf import settings @@ -21,68 +21,71 @@ class Migration(migrations.Migration): name='ActivityTag', fields=[ ('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")), - ('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={ - 'verbose_name': 'tag', 'verbose_name_plural': 'tags', + 'verbose_name': 'tag', }, ), migrations.CreateModel( name='ActivityTemplate', fields=[ ('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()), ('has_perm', models.NullBooleanField()), - ('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')), - ('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')), + ('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')), + ('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')), ], options={ - 'verbose_name': 'template activité', 'verbose_name_plural': 'templates activité', + 'verbose_name': 'template activité', }, ), migrations.CreateModel( name='Event', fields=[ - ('title', models.CharField(max_length=200, verbose_name="Nom de l'évènement")), - ('slug', models.SlugField(help_text="Seulement des lettres, des chiffres oules caractères '_' ou '-'.", primary_key=True, serialize=False, unique=True, verbose_name='Identificateur')), - ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='Date de création')), - ('description', models.TextField(verbose_name='Description')), - ('beginning_date', models.DateTimeField(verbose_name='Date de début')), - ('ending_date', models.DateTimeField(verbose_name='Date de fin')), + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200, verbose_name="nom de l'évènement")), + ('slug', models.SlugField(help_text="Seulement des lettres, des chiffres oules caractères '_' ou '-'.", unique=True, verbose_name='identificateur')), + ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='date de création')), + ('description', models.TextField(verbose_name='description')), + ('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)), ], options={ - 'verbose_name': 'évènement', 'verbose_name_plural': 'évènements', + 'verbose_name': 'évènement', }, ), migrations.CreateModel( name='Place', fields=[ ('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)), ], options={ - 'verbose_name': 'lieu', 'verbose_name_plural': 'lieux', + 'verbose_name': 'lieu', }, ), migrations.CreateModel( name='Activity', 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')), + ('beginning', models.DateTimeField(verbose_name='heure de début')), + ('end', models.DateTimeField(verbose_name='heure de fin')), ], options={ - 'verbose_name': 'activité', 'verbose_name_plural': 'activités', + 'verbose_name': 'activité', }, bases=('event.activitytemplate',), ), diff --git a/event/tests.py b/event/tests.py index 38b2add..fbffaba 100644 --- a/event/tests.py +++ b/event/tests.py @@ -44,51 +44,56 @@ class ActivityInheritanceTest(TestCase): self.template_act = ActivityTemplate.objects.create() self.real_act = Activity.objects.create( 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.assertEqual(self.real_act.get_herited('title'), "parent") self.real_act.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.assertEqual(self.real_act.get_herited('description'), "parent") self.real_act.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.assertEqual(self.real_act.get_herited('remarks'), "parent") self.real_act.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.assertEqual(self.real_act.get_herited('is_public'), True) self.real_act.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.assertEqual(self.real_act.get_herited('has_perm'), True) self.real_act.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.assertEqual(self.real_act.get_herited('min_perm'), 42) self.real_act.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.assertEqual(self.real_act.get_herited('max_perm'), 42) self.real_act.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.assertEqual( self.real_act.get_herited('place').get(), @@ -100,7 +105,7 @@ class ActivityInheritanceTest(TestCase): self.aqua ) - def test_inherites_tags(self): + def test_inherits_tags(self): self.template_act.tags.add(self.tag_foo) self.assertEqual( self.real_act.get_herited('tags').get(), diff --git a/shared/migrations/__init__.py b/shared/migrations/__init__.py deleted file mode 100644 index e69de29..0000000