From 22e01ad2b2074c432040f371aa789f5c3e56fe97 Mon Sep 17 00:00:00 2001 From: Juliette Luiselli Date: Mon, 11 Feb 2019 23:51:38 +0100 Subject: [PATCH 1/5] permiere version profile --- annuaire/settings.py | 2 +- fiches/admin.py | 2 ++ fiches/migrations/0001_initial.py | 41 +++++++++++++++++++++++++++++++ fiches/models.py | 20 +++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 fiches/migrations/0001_initial.py diff --git a/annuaire/settings.py b/annuaire/settings.py index 04d975a..614c878 100644 --- a/annuaire/settings.py +++ b/annuaire/settings.py @@ -27,7 +27,6 @@ DEBUG = True ALLOWED_HOSTS = [] - # Application definition INSTALLED_APPS = [ @@ -37,6 +36,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'fiches' ] MIDDLEWARE = [ diff --git a/fiches/admin.py b/fiches/admin.py index 8c38f3f..39d9d23 100644 --- a/fiches/admin.py +++ b/fiches/admin.py @@ -1,3 +1,5 @@ from django.contrib import admin +from fiches.models import Profile # Register your models here. +admin.site.register(Profile) \ No newline at end of file diff --git a/fiches/migrations/0001_initial.py b/fiches/migrations/0001_initial.py new file mode 100644 index 0000000..4269ef8 --- /dev/null +++ b/fiches/migrations/0001_initial.py @@ -0,0 +1,41 @@ +# Generated by Django 2.2b1 on 2019-02-11 22:49 + +from django.conf import settings +import django.core.validators +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), + ] + + operations = [ + migrations.CreateModel( + name='Department', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('full_name', models.CharField(max_length=1023, verbose_name='nom')), + ('nickname', models.CharField(max_length=1023, verbose_name='surnom')), + ('picture', models.ImageField(upload_to='picture', verbose_name='photo')), + ('promotion', models.IntegerField(validators=[django.core.validators.MinValueValidator(1980)], verbose_name='promotion')), + ('birth_date', models.DateField(verbose_name='date de naissance')), + ('thurne', models.CharField(max_length=100, verbose_name='thurne')), + ('text_field', models.TextField(verbose_name='champ libre')), + ('printing', models.BooleanField(verbose_name="apparaître sur l'annuaire papier ?")), + ('keep_me', models.BooleanField(verbose_name='conserver la fiche annuaire ?')), + ('department', models.ManyToManyField(to='fiches.Department', verbose_name='département')), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='utilisateur')), + ], + ), + ] diff --git a/fiches/models.py b/fiches/models.py index 71a8362..6bc39a4 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -1,3 +1,23 @@ from django.db import models +from django.core.validators import MinValueValidator +from django.utils.translation import ugettext_lazy as _ +from django.contrib.auth.models import User # Create your models here. + +class Profile(models.Model): + user = models.OneToOneField(User, on_delete = models.CASCADE,verbose_name = _('utilisateur')) + full_name = models.CharField(max_length = 1023, verbose_name = _('nom')) + nickname = models.CharField(max_length = 1023, verbose_name = _('surnom')) + picture = models.ImageField(upload_to = 'picture', verbose_name = _('photo')) + department = models.ManyToManyField("Department", verbose_name = _('département')) + promotion = models.IntegerField(validators = [MinValueValidator(1980)], verbose_name = _('promotion')) + birth_date = models.DateField(verbose_name = _('date de naissance')) + thurne = models.CharField(max_length = 100, verbose_name = _('thurne')) + text_field = models.TextField(verbose_name = _('champ libre')) + printing = models.BooleanField(verbose_name = _("apparaître sur l'annuaire papier ?")) + keep_me = models.BooleanField(verbose_name = _('conserver la fiche annuaire ?')) +# Champ pour les très vielleux plus en scolarité qui veulent garder leur fiche annuaire + +class Department(models.Model): + pass From 223fae94c40a2371133ca4532ab6b9a98c437a0b Mon Sep 17 00:00:00 2001 From: Juliette Luiselli Date: Wed, 13 Feb 2019 13:15:01 +0100 Subject: [PATCH 2/5] new models: Department, Phone and Social --- fiches/admin.py | 8 ++++- fiches/migrations/0002_department_name.py | 19 ++++++++++++ fiches/migrations/0003_phone_social.py | 32 ++++++++++++++++++++ fiches/migrations/0004_auto_20190213_1212.py | 18 +++++++++++ fiches/models.py | 14 +++++++-- 5 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 fiches/migrations/0002_department_name.py create mode 100644 fiches/migrations/0003_phone_social.py create mode 100644 fiches/migrations/0004_auto_20190213_1212.py diff --git a/fiches/admin.py b/fiches/admin.py index 39d9d23..97f45d4 100644 --- a/fiches/admin.py +++ b/fiches/admin.py @@ -1,5 +1,11 @@ from django.contrib import admin from fiches.models import Profile +from fiches.models import Department +from fiches.models import Phone +from fiches.models import Social # Register your models here. -admin.site.register(Profile) \ No newline at end of file +admin.site.register(Profile) +admin.site.register(Department) +admin.site.register(Phone) +admin.site.register(Social) \ No newline at end of file diff --git a/fiches/migrations/0002_department_name.py b/fiches/migrations/0002_department_name.py new file mode 100644 index 0000000..35a9fec --- /dev/null +++ b/fiches/migrations/0002_department_name.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2b1 on 2019-02-13 11:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fiches', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='department', + name='name', + field=models.CharField(default=' ', max_length=1023, verbose_name='nom du département'), + preserve_default=False, + ), + ] diff --git a/fiches/migrations/0003_phone_social.py b/fiches/migrations/0003_phone_social.py new file mode 100644 index 0000000..fe35941 --- /dev/null +++ b/fiches/migrations/0003_phone_social.py @@ -0,0 +1,32 @@ +# Generated by Django 2.2b1 on 2019-02-13 12:07 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('fiches', '0002_department_name'), + ] + + operations = [ + migrations.CreateModel( + name='Social', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=1023, verbose_name='type')), + ('content', models.TextField(verbose_name='contenu')), + ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), + ], + ), + migrations.CreateModel( + name='Phone', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=1023, verbose_name='type')), + ('number', models.CharField(max_length=1023, verbose_name='numéro')), + ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), + ], + ), + ] diff --git a/fiches/migrations/0004_auto_20190213_1212.py b/fiches/migrations/0004_auto_20190213_1212.py new file mode 100644 index 0000000..f714cea --- /dev/null +++ b/fiches/migrations/0004_auto_20190213_1212.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2b1 on 2019-02-13 12:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fiches', '0003_phone_social'), + ] + + operations = [ + migrations.AlterField( + model_name='social', + name='content', + field=models.CharField(max_length=1023, verbose_name='contenu'), + ), + ] diff --git a/fiches/models.py b/fiches/models.py index 6bc39a4..60de0a6 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -6,7 +6,7 @@ from django.contrib.auth.models import User # Create your models here. class Profile(models.Model): - user = models.OneToOneField(User, on_delete = models.CASCADE,verbose_name = _('utilisateur')) + user = models.OneToOneField(User, on_delete = models.CASCADE, verbose_name = _('utilisateur')) full_name = models.CharField(max_length = 1023, verbose_name = _('nom')) nickname = models.CharField(max_length = 1023, verbose_name = _('surnom')) picture = models.ImageField(upload_to = 'picture', verbose_name = _('photo')) @@ -20,4 +20,14 @@ class Profile(models.Model): # Champ pour les très vielleux plus en scolarité qui veulent garder leur fiche annuaire class Department(models.Model): - pass + name = models.CharField(max_length = 1023, verbose_name = _('nom du département')) + +class Phone(models.Model): + profile = models.OneToOneField(Profile, on_delete = models.CASCADE, verbose_name = _('profil')) + name = models.CharField(max_length = 1023, verbose_name = _('type')) + number = models.CharField(max_length = 1023, verbose_name = _('numéro')) + +class Social(models.Model): + profile = models.OneToOneField(Profile, on_delete = models.CASCADE, verbose_name = _('profil')) + name = models.CharField(max_length = 1023, verbose_name = _('type')) + content = models.CharField(max_length = 1023, verbose_name = _('contenu')) \ No newline at end of file From 799a62798ca052ff754d847357982cb7ebf4934d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 18 Feb 2019 21:47:03 +0100 Subject: [PATCH 3/5] black --- fiches/models.py | 49 ++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/fiches/models.py b/fiches/models.py index 60de0a6..e44bcb4 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -3,31 +3,40 @@ from django.core.validators import MinValueValidator from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User -# Create your models here. class Profile(models.Model): - user = models.OneToOneField(User, on_delete = models.CASCADE, verbose_name = _('utilisateur')) - full_name = models.CharField(max_length = 1023, verbose_name = _('nom')) - nickname = models.CharField(max_length = 1023, verbose_name = _('surnom')) - picture = models.ImageField(upload_to = 'picture', verbose_name = _('photo')) - department = models.ManyToManyField("Department", verbose_name = _('département')) - promotion = models.IntegerField(validators = [MinValueValidator(1980)], verbose_name = _('promotion')) - birth_date = models.DateField(verbose_name = _('date de naissance')) - thurne = models.CharField(max_length = 100, verbose_name = _('thurne')) - text_field = models.TextField(verbose_name = _('champ libre')) - printing = models.BooleanField(verbose_name = _("apparaître sur l'annuaire papier ?")) - keep_me = models.BooleanField(verbose_name = _('conserver la fiche annuaire ?')) -# Champ pour les très vielleux plus en scolarité qui veulent garder leur fiche annuaire + user = models.OneToOneField( + User, on_delete=models.CASCADE, verbose_name=_("utilisateur") + ) + full_name = models.CharField(max_length=1023, verbose_name=_("nom")) + nickname = models.CharField(max_length=1023, verbose_name=_("surnom")) + picture = models.ImageField(upload_to="picture", verbose_name=_("photo")) + department = models.ManyToManyField("Department", verbose_name=_("département")) + promotion = models.IntegerField( + validators=[MinValueValidator(1980)], verbose_name=_("promotion") + ) + birth_date = models.DateField(verbose_name=_("date de naissance")) + thurne = models.CharField(max_length=100, verbose_name=_("thurne")) + text_field = models.TextField(verbose_name=_("champ libre")) + printing = models.BooleanField(verbose_name=_("apparaître sur l'annuaire papier ?")) + keep_me = models.BooleanField(verbose_name=_("conserver la fiche annuaire ?")) + class Department(models.Model): - name = models.CharField(max_length = 1023, verbose_name = _('nom du département')) + name = models.CharField(max_length=1023, verbose_name=_("nom du département")) + class Phone(models.Model): - profile = models.OneToOneField(Profile, on_delete = models.CASCADE, verbose_name = _('profil')) - name = models.CharField(max_length = 1023, verbose_name = _('type')) - number = models.CharField(max_length = 1023, verbose_name = _('numéro')) + profile = models.OneToOneField( + Profile, on_delete=models.CASCADE, verbose_name=_("profil") + ) + name = models.CharField(max_length=1023, verbose_name=_("type")) + number = models.CharField(max_length=1023, verbose_name=_("numéro")) + class Social(models.Model): - profile = models.OneToOneField(Profile, on_delete = models.CASCADE, verbose_name = _('profil')) - name = models.CharField(max_length = 1023, verbose_name = _('type')) - content = models.CharField(max_length = 1023, verbose_name = _('contenu')) \ No newline at end of file + profile = models.OneToOneField( + Profile, on_delete=models.CASCADE, verbose_name=_("profil") + ) + name = models.CharField(max_length=1023, verbose_name=_("type")) + content = models.CharField(max_length=1023, verbose_name=_("contenu")) From 72a182fdcb7563ffb6853d90575aae118162a4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 18 Feb 2019 21:52:07 +0100 Subject: [PATCH 4/5] squash migrations --- fiches/migrations/0001_initial.py | 21 ++++++++++++- fiches/migrations/0002_department_name.py | 19 ------------ fiches/migrations/0003_phone_social.py | 32 -------------------- fiches/migrations/0004_auto_20190213_1212.py | 18 ----------- 4 files changed, 20 insertions(+), 70 deletions(-) delete mode 100644 fiches/migrations/0002_department_name.py delete mode 100644 fiches/migrations/0003_phone_social.py delete mode 100644 fiches/migrations/0004_auto_20190213_1212.py diff --git a/fiches/migrations/0001_initial.py b/fiches/migrations/0001_initial.py index 4269ef8..88a86cb 100644 --- a/fiches/migrations/0001_initial.py +++ b/fiches/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2b1 on 2019-02-11 22:49 +# Generated by Django 2.2b1 on 2019-02-18 20:46 from django.conf import settings import django.core.validators @@ -19,6 +19,7 @@ class Migration(migrations.Migration): name='Department', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=1023, verbose_name='nom du département')), ], ), migrations.CreateModel( @@ -38,4 +39,22 @@ class Migration(migrations.Migration): ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='utilisateur')), ], ), + migrations.CreateModel( + name='Social', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=1023, verbose_name='type')), + ('content', models.CharField(max_length=1023, verbose_name='contenu')), + ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), + ], + ), + migrations.CreateModel( + name='Phone', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=1023, verbose_name='type')), + ('number', models.CharField(max_length=1023, verbose_name='numéro')), + ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), + ], + ), ] diff --git a/fiches/migrations/0002_department_name.py b/fiches/migrations/0002_department_name.py deleted file mode 100644 index 35a9fec..0000000 --- a/fiches/migrations/0002_department_name.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.2b1 on 2019-02-13 11:43 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiches', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='department', - name='name', - field=models.CharField(default=' ', max_length=1023, verbose_name='nom du département'), - preserve_default=False, - ), - ] diff --git a/fiches/migrations/0003_phone_social.py b/fiches/migrations/0003_phone_social.py deleted file mode 100644 index fe35941..0000000 --- a/fiches/migrations/0003_phone_social.py +++ /dev/null @@ -1,32 +0,0 @@ -# Generated by Django 2.2b1 on 2019-02-13 12:07 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiches', '0002_department_name'), - ] - - operations = [ - migrations.CreateModel( - name='Social', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=1023, verbose_name='type')), - ('content', models.TextField(verbose_name='contenu')), - ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), - ], - ), - migrations.CreateModel( - name='Phone', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=1023, verbose_name='type')), - ('number', models.CharField(max_length=1023, verbose_name='numéro')), - ('profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='fiches.Profile', verbose_name='profil')), - ], - ), - ] diff --git a/fiches/migrations/0004_auto_20190213_1212.py b/fiches/migrations/0004_auto_20190213_1212.py deleted file mode 100644 index f714cea..0000000 --- a/fiches/migrations/0004_auto_20190213_1212.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2b1 on 2019-02-13 12:12 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiches', '0003_phone_social'), - ] - - operations = [ - migrations.AlterField( - model_name='social', - name='content', - field=models.CharField(max_length=1023, verbose_name='contenu'), - ), - ] From f4e86ee8492070b1c1cb0d02961bc9b8cd5ad79a Mon Sep 17 00:00:00 2001 From: Juliette Luiselli Date: Mon, 18 Feb 2019 22:03:38 +0100 Subject: [PATCH 5/5] fields made optional --- fiches/migrations/0001_initial.py | 16 ++++++++-------- fiches/models.py | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/fiches/migrations/0001_initial.py b/fiches/migrations/0001_initial.py index 88a86cb..66f59ec 100644 --- a/fiches/migrations/0001_initial.py +++ b/fiches/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2b1 on 2019-02-18 20:46 +# Generated by Django 2.2b1 on 2019-02-18 21:05 from django.conf import settings import django.core.validators @@ -27,14 +27,14 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('full_name', models.CharField(max_length=1023, verbose_name='nom')), - ('nickname', models.CharField(max_length=1023, verbose_name='surnom')), - ('picture', models.ImageField(upload_to='picture', verbose_name='photo')), + ('nickname', models.CharField(blank=True, max_length=1023, verbose_name='surnom')), + ('picture', models.ImageField(blank=True, upload_to='picture', verbose_name='photo')), ('promotion', models.IntegerField(validators=[django.core.validators.MinValueValidator(1980)], verbose_name='promotion')), - ('birth_date', models.DateField(verbose_name='date de naissance')), - ('thurne', models.CharField(max_length=100, verbose_name='thurne')), - ('text_field', models.TextField(verbose_name='champ libre')), - ('printing', models.BooleanField(verbose_name="apparaître sur l'annuaire papier ?")), - ('keep_me', models.BooleanField(verbose_name='conserver la fiche annuaire ?')), + ('birth_date', models.DateField(blank=True, verbose_name='date de naissance')), + ('thurne', models.CharField(blank=True, max_length=100, verbose_name='thurne')), + ('text_field', models.TextField(blank=True, verbose_name='champ libre')), + ('printing', models.BooleanField(default=False, verbose_name="apparaître sur l'annuaire papier ?")), + ('keep_me', models.BooleanField(default=False, verbose_name='conserver la fiche annuaire ?')), ('department', models.ManyToManyField(to='fiches.Department', verbose_name='département')), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='utilisateur')), ], diff --git a/fiches/models.py b/fiches/models.py index e44bcb4..beeac8d 100644 --- a/fiches/models.py +++ b/fiches/models.py @@ -9,17 +9,23 @@ class Profile(models.Model): User, on_delete=models.CASCADE, verbose_name=_("utilisateur") ) full_name = models.CharField(max_length=1023, verbose_name=_("nom")) - nickname = models.CharField(max_length=1023, verbose_name=_("surnom")) - picture = models.ImageField(upload_to="picture", verbose_name=_("photo")) + nickname = models.CharField(blank=True, max_length=1023, verbose_name=_("surnom")) + picture = models.ImageField( + blank=True, upload_to="picture", verbose_name=_("photo") + ) department = models.ManyToManyField("Department", verbose_name=_("département")) promotion = models.IntegerField( validators=[MinValueValidator(1980)], verbose_name=_("promotion") ) - birth_date = models.DateField(verbose_name=_("date de naissance")) - thurne = models.CharField(max_length=100, verbose_name=_("thurne")) - text_field = models.TextField(verbose_name=_("champ libre")) - printing = models.BooleanField(verbose_name=_("apparaître sur l'annuaire papier ?")) - keep_me = models.BooleanField(verbose_name=_("conserver la fiche annuaire ?")) + birth_date = models.DateField(blank=True, verbose_name=_("date de naissance")) + thurne = models.CharField(blank=True, max_length=100, verbose_name=_("thurne")) + text_field = models.TextField(blank=True, verbose_name=_("champ libre")) + printing = models.BooleanField( + default=False, verbose_name=_("apparaître sur l'annuaire papier ?") + ) + keep_me = models.BooleanField( + default=False, verbose_name=_("conserver la fiche annuaire ?") + ) class Department(models.Model):