www-bocal/mainsite/models.py

28 lines
1,010 B
Python
Raw Normal View History

2017-09-21 10:58:19 +02:00
from django.db import models
2017-09-21 19:58:42 +02:00
from django.db.models import DateField, \
2017-09-21 11:34:40 +02:00
CharField, \
BooleanField
2017-09-21 10:58:19 +02:00
2017-09-21 11:34:40 +02:00
class Publication(models.Model):
num = CharField('Numéro du BOcal', max_length=128)
2017-09-21 19:58:42 +02:00
url = CharField('Adresse sur le site', max_length=512)
# ^ This is not a URLField because we need internal URLS, eg `/static/blah`
2017-09-21 11:34:40 +02:00
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)',
2017-09-21 19:58:42 +02:00
max_length=512,
blank=True)
2017-09-21 11:34:40 +02:00
custom_name = CharField('Nom customisé',
help_text='Vide pour laisser le numéro seulement',
2017-09-21 19:58:42 +02:00
max_length=128,
blank=True)
2017-09-21 11:34:40 +02:00
def __str__(self):
if self.custom_name:
return self.custom_name
return 'BOcal n°{}'.format(self.num)