Introduce django-solo for site configuration
This commit is contained in:
parent
5ad0190446
commit
db0f7fa5b2
4 changed files with 45 additions and 0 deletions
|
@ -27,6 +27,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'solo',
|
||||
'mainsite',
|
||||
]
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
27
mainsite/migrations/0003_siteconfiguration.py
Normal file
27
mainsite/migrations/0003_siteconfiguration.py
Normal 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',
|
||||
},
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue