From ce151d0f57acdcdb3e7428f5eb445b87f2675469 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 30 Jan 2018 21:39:44 +0100 Subject: [PATCH] Page d'administration. --- settings/templates/settings/settings.html | 63 ++++++++++++++++++++--- settings/urls.py | 11 ++++ settings/views.py | 13 ++++- site_tps/urls.py | 1 + templates/nav_bar.html | 2 +- 5 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 settings/urls.py diff --git a/settings/templates/settings/settings.html b/settings/templates/settings/settings.html index b287a0b..062fc0e 100644 --- a/settings/templates/settings/settings.html +++ b/settings/templates/settings/settings.html @@ -1,11 +1,62 @@ {% extends "base.html" %} +{% block content %}

Page d'administration du site

Liste des catégories

-Créer une nouvelle catégorie - + + + Créer une nouvelle catégorie + + + + + + + + {% for c in categories %} + + + + + + {% endfor %} +
Nom de la catégorieNombre de contenus
{{c.name}}{{c.content_set.count}}Éditer

Réglages

+

Réglages du site

+ + + Éditer + + + + + + + + + + +
Upload + {% if site_settings.allow_upload %} + Autorisé + {% else %} + Non autorisé + {% endif %} +
Message d'accueil{{site_settings.home_message}}
+ +

Réglage du contenu

+ + + Éditer + + + + + + + + + + +
URL du FTP{{content_settings.ftp_url}}
Identifiant du FTP{{content_settings.ftp_id}}
+{% endblock %} diff --git a/settings/urls.py b/settings/urls.py new file mode 100644 index 0000000..25bfe15 --- /dev/null +++ b/settings/urls.py @@ -0,0 +1,11 @@ +from django.urls import path +from .views import SettingsView + +app_name = 'settings' +urlpatterns = [ + path( + '', + SettingsView.as_view(), + name='index' + ), +] diff --git a/settings/views.py b/settings/views.py index 91ea44a..4f10f14 100644 --- a/settings/views.py +++ b/settings/views.py @@ -1,3 +1,12 @@ -from django.shortcuts import render +from django.views.generic import TemplateView +from content.models import Category +from .models import ContentSettings, SiteSettings -# Create your views here. +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() + return context diff --git a/site_tps/urls.py b/site_tps/urls.py index 0edf049..d8d3e60 100644 --- a/site_tps/urls.py +++ b/site_tps/urls.py @@ -22,4 +22,5 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', views.home), path('content/', include('content.urls')), + path('settings/', include('settings.urls')), ] diff --git a/templates/nav_bar.html b/templates/nav_bar.html index 1eb5f93..86105bc 100644 --- a/templates/nav_bar.html +++ b/templates/nav_bar.html @@ -26,7 +26,7 @@ {% endfor %}
  • Vote
  • -
  • Nouvelle catégorie
  • +
  • Administration