Merge branch 'ju/profile' into 'master'

ajout de modèles

See merge request klub-dev-ens/annuaire!1
This commit is contained in:
Martin Pepin 2019-02-18 22:08:57 +01:00
commit ae2d909b7c
4 changed files with 115 additions and 2 deletions

View file

@ -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 = [

View file

@ -1,3 +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)
admin.site.register(Department)
admin.site.register(Phone)
admin.site.register(Social)

View file

@ -0,0 +1,60 @@
# Generated by Django 2.2b1 on 2019-02-18 21:05
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')),
('name', models.CharField(max_length=1023, verbose_name='nom du département')),
],
),
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(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(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')),
],
),
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')),
],
),
]

View file

@ -1,3 +1,48 @@
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(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(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):
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"))