From aa4812e337b7c491b8f6fa1a7fbbb605392d4084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Thu, 21 Sep 2017 11:34:40 +0200 Subject: [PATCH] Add tentative model for a publication --- mainsite/migrations/0001_initial.py | 26 ++++++++++++++++++++++++++ mainsite/models.py | 23 ++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 mainsite/migrations/0001_initial.py diff --git a/mainsite/migrations/0001_initial.py b/mainsite/migrations/0001_initial.py new file mode 100644 index 0000000..f0cf0fd --- /dev/null +++ b/mainsite/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.5 on 2017-09-21 09:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Publication', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('num', models.CharField(max_length=128, verbose_name='Numéro du BOcal')), + ('url', models.URLField(verbose_name='Adresse sur le site')), + ('date', models.DateField(verbose_name='Publication')), + ('is_special', models.BooleanField(default=False, help_text='Numéro du BOcal non-numéroté', verbose_name='Numéro spécial')), + ], + ), + ] diff --git a/mainsite/models.py b/mainsite/models.py index 71a8362..e3701b7 100644 --- a/mainsite/models.py +++ b/mainsite/models.py @@ -1,3 +1,24 @@ from django.db import models +from django.db.models import URLField, \ + DateField, \ + CharField, \ + BooleanField -# Create your models here. + +class Publication(models.Model): + num = CharField('Numéro du BOcal', max_length=128) + url = URLField('Adresse sur le site') + date = DateField('Publication') + is_special = BooleanField('Numéro spécial', + help_text='Numéro du BOcal non-numéroté', + default=False) + descr = CharField('Description (optionnelle)', + max_length=512), + custom_name = CharField('Nom customisé', + help_text='Vide pour laisser le numéro seulement', + max_length=128), + + def __str__(self): + if self.custom_name: + return self.custom_name + return 'BOcal n°{}'.format(self.num)