Introduce django-solo for site configuration

This commit is contained in:
Théophile Bastian 2017-09-22 18:07:38 +02:00
parent 5ad0190446
commit db0f7fa5b2
4 changed files with 45 additions and 0 deletions

View file

@ -27,6 +27,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'solo',
'mainsite',
]

View file

@ -1,6 +1,8 @@
from django.contrib import admin
from solo.admin import SingletonModelAdmin
from . import models
admin.site.register(models.SiteConfiguration, SingletonModelAdmin)
admin.site.register(models.Publication)
admin.site.register(models.PublicationYear)

View file

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-22 16:04
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mainsite', '0002_auto_20170922_1438'),
]
operations = [
migrations.CreateModel(
name='SiteConfiguration',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('homepageText', models.TextField(verbose_name="Texte de la page d'accueil (HTML)")),
('writearticleText', models.TextField(verbose_name='Texte de la page « écrire » (HTML)')),
('email', models.CharField(help_text='Attention au spam…', max_length=128, verbose_name='Adresse de contact du BOcal')),
],
options={
'verbose_name': 'Configuration du site',
},
),
]

View file

@ -4,10 +4,25 @@ from django.db.models import DateField, \
BooleanField, \
IntegerField, \
TextField
from solo.models import SingletonModel
import datetime
class SiteConfiguration(SingletonModel):
homepageText = TextField("Texte de la page d'accueil (HTML)")
writearticleText = TextField("Texte de la page « écrire » (HTML)")
email = CharField("Adresse de contact du BOcal",
max_length=128,
help_text="Attention au spam…")
def __str__(self):
return "Configuration du site"
class Meta:
verbose_name = "Configuration du site"
class Publication(models.Model):
num = CharField('Numéro du BOcal', max_length=128)
url = CharField('Adresse sur le site', max_length=512)