From 8cdef202c710f24e09ffdcfbee58e0e5acb001b3 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 22 Feb 2018 20:55:10 +0100 Subject: [PATCH] =?UTF-8?q?=C3=89dition=20d'=C3=A9coles=20et=20r=C3=A9glag?= =?UTF-8?q?es=20g=C3=A9n=C3=A9raux.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings/templates/settings/settings.html | 33 +++++++++-------------- settings/urls.py | 7 ++++- settings/views.py | 20 +++++++++++--- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/settings/templates/settings/settings.html b/settings/templates/settings/settings.html index c2be7b6..6fbd4a2 100644 --- a/settings/templates/settings/settings.html +++ b/settings/templates/settings/settings.html @@ -3,11 +3,9 @@

Page d'administration du site

Liste des catégories

- + Créer une nouvelle catégorie -
-
@@ -19,11 +17,11 @@ @@ -34,11 +32,9 @@

Écoles

- + Inscrire une nouvelle école -
-
Nom de la catégorie{{c.name}} {{c.content_set.count}} - + Éditer - + Supprimer
@@ -48,13 +44,12 @@ - @@ -62,12 +57,10 @@
Nom
{{school.group.name}} {{school.group.user_set.count}} - + + Éditer - - - Supprimer + +

Réglages

Réglages du site

- - + + Éditer -
-
@@ -85,13 +78,11 @@
Upload
-

Réglages du contenu

+

Réglage du contenu

- + Éditer -
-
diff --git a/settings/urls.py b/settings/urls.py index 25bfe15..2504f22 100644 --- a/settings/urls.py +++ b/settings/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from .views import SettingsView +from .views import SettingsView, EditSiteSettingsView app_name = 'settings' urlpatterns = [ @@ -8,4 +8,9 @@ urlpatterns = [ SettingsView.as_view(), name='index' ), + path( + 'site_settings', + EditSiteSettingsView.as_view(), + name='site-settings' + ), ] diff --git a/settings/views.py b/settings/views.py index 12301ae..188d46d 100644 --- a/settings/views.py +++ b/settings/views.py @@ -1,14 +1,28 @@ -from django.views.generic import TemplateView +from django.views.generic import TemplateView, UpdateView +from django.urls import reverse_lazy from content.models import Category from users.models import SchoolProfile from .models import ContentSettings, SiteSettings + class SettingsView(TemplateView): template_name = "settings/settings.html" + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['categories'] = Category.objects.all() - context['site_settings'],_ = SiteSettings.objects.get_or_create() - context['content_settings'],_ = ContentSettings.objects.get_or_create() + context['site_settings'], _ = SiteSettings.objects.get_or_create() + context['content_settings'], _ = ContentSettings.objects.get_or_create() context['schools'] = SchoolProfile.objects.all() + context['settings'] = True return context + +class EditSiteSettingsView(UpdateView): + template_name = "edit.html" + model = SiteSettings + fields = '__all__' + success_url = reverse_lazy('settings:index') + + def get_object(self, queryset=None): + obj,_ = self.model.objects.get_or_create() + return obj
URL du FTP