From bda2980e1a3143be3dbe025bd965f24a96072327 Mon Sep 17 00:00:00 2001 From: Klafyvel Date: Thu, 1 Mar 2018 12:02:22 +0100 Subject: [PATCH] Ajout d'options de personnalisation --- .../migrations/0002_auto_20180301_1047.py | 28 +++++++++++++++++++ settings/models.py | 12 ++++++++ settings/templates/settings/settings.html | 24 ++++++++++++++++ site_tps/views.py | 1 + templates/nav_bar.html | 10 ++++++- 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 settings/migrations/0002_auto_20180301_1047.py diff --git a/settings/migrations/0002_auto_20180301_1047.py b/settings/migrations/0002_auto_20180301_1047.py new file mode 100644 index 0000000..fbfe96d --- /dev/null +++ b/settings/migrations/0002_auto_20180301_1047.py @@ -0,0 +1,28 @@ +# Generated by Django 2.0.1 on 2018-03-01 10:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('settings', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='sitesettings', + name='event_poster', + field=models.ImageField(null=True, upload_to='', verbose_name="Affiche de l'événement"), + ), + migrations.AddField( + model_name='sitesettings', + name='min_number_of_categories', + field=models.PositiveIntegerField(default=0, verbose_name='Nombre minimal de catégories dans laquelle participer'), + ), + migrations.AddField( + model_name='sitesettings', + name='site_logo', + field=models.ImageField(null=True, upload_to='', verbose_name='Logo du site'), + ), + ] diff --git a/settings/models.py b/settings/models.py index 73ec1cd..b0dc471 100644 --- a/settings/models.py +++ b/settings/models.py @@ -13,6 +13,18 @@ class SiteSettings(models.Model): verbose_name="Message de la page d'accueil", default="" ) + site_logo = models.ImageField( + verbose_name="Logo du site", + null=True + ) + event_poster = models.ImageField( + verbose_name="Affiche de l'événement", + null=True + ) + min_number_of_categories = models.PositiveIntegerField( + verbose_name="Nombre minimal de catégories dans laquelle participer", + default=0, + ) @classmethod def get_settings(cls): diff --git a/settings/templates/settings/settings.html b/settings/templates/settings/settings.html index d09b3a1..8114371 100644 --- a/settings/templates/settings/settings.html +++ b/settings/templates/settings/settings.html @@ -82,5 +82,29 @@ Message d'accueil {{site_settings.home_message}} + + Logo du site + + {% if site_settings.site_logo %} + logo + {% else %} + Pas de logo + {% endif %} + + + + Affiche de l'événement + + {% if site_settings.event_poster %} + affiche + {% else %} + Pas d'affiche + {% endif %} + + + + Nombre minimal de catégories + {{ site_settings.min_number_of_categories }} + {% endblock %} diff --git a/site_tps/views.py b/site_tps/views.py index a90820c..97f50ac 100644 --- a/site_tps/views.py +++ b/site_tps/views.py @@ -7,4 +7,5 @@ def home(request): return render(request, "home.html", { 'upload_allowed': settings.allow_upload, 'message': settings.home_message, + 'poster': settings.event_poster, }) diff --git a/templates/nav_bar.html b/templates/nav_bar.html index 01edf3e..28560bb 100644 --- a/templates/nav_bar.html +++ b/templates/nav_bar.html @@ -1,7 +1,15 @@ {% load categories %} +{% load load_settings %} {% load_categories %} +{% load_site_settings %}