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