Page d'administration.

This commit is contained in:
Hugo LEVY-FALK 2018-01-30 21:39:44 +01:00
parent 861a747b0b
commit ce151d0f57
5 changed files with 81 additions and 9 deletions

View file

@ -1,11 +1,62 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %}
<h1>Page d'administration du site</h1> <h1>Page d'administration du site</h1>
<h2>Liste des catégories</h2> <h2>Liste des catégories</h2>
<a href="{% url 'content:category-new' %}">Créer une nouvelle catégorie</a> <a class="btn btn-primary btn-sm" role="button" href="{% url 'content:category-new' %}">
<ul> <i class="glyphicon glyphicon-plus"></i>
{% for c in categories %} Créer une nouvelle catégorie
<li>c.name</li> </a>
{% endfor %} <table class="table table-striped">
</ul> <tr>
<th>Nom de la catégorie</th>
<th>Nombre de contenus</th>
<th></th>
</tr>
{% for c in categories %}
<tr>
<td><a href="{{c.get_absolute_url}}">{{c.name}}</a></td>
<td>{{c.content_set.count}}</td>
<td><a href="">Éditer</a></td>
</tr>
{% endfor %}
</table>
<h2>Réglages</h2> <h2>Réglages</h2>
<h3>Réglages du site</h3>
<a class="btn btn-primary btn-sm" href="">
<i class="glyphicon glyphicon-edit"></i>
Éditer
</a>
<table class="table table-striped">
<tr>
<th>Upload</th>
<td>
{% if site_settings.allow_upload %}
Autorisé
{% else %}
Non autorisé
{% endif %}
</td>
</tr>
<tr>
<th>Message d'accueil</th>
<td>{{site_settings.home_message}}</td>
</tr>
</table>
<h3>Réglage du contenu</h3>
<a class="btn btn-primary btn-sm" href="">
<i class="glyphicon glyphicon-edit"></i>
Éditer
</a>
<table class="table table-striped">
<tr>
<th>URL du FTP</th>
<td>{{content_settings.ftp_url}}</td>
</tr>
<tr>
<th>Identifiant du FTP</th>
<td>{{content_settings.ftp_id}}</td>
</tr>
</table>
{% endblock %}

11
settings/urls.py Normal file
View file

@ -0,0 +1,11 @@
from django.urls import path
from .views import SettingsView
app_name = 'settings'
urlpatterns = [
path(
'',
SettingsView.as_view(),
name='index'
),
]

View file

@ -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

View file

@ -22,4 +22,5 @@ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', views.home), path('', views.home),
path('content/', include('content.urls')), path('content/', include('content.urls')),
path('settings/', include('settings.urls')),
] ]

View file

@ -26,7 +26,7 @@
</a></li> </a></li>
{% endfor %} {% endfor %}
<li><a href="">Vote</a></li> <li><a href="">Vote</a></li>
<li><a href="{% url 'content:category-new' %}">Nouvelle catégorie</a></li> <li><a href="{% url 'settings:index' %}">Administration</a></li>
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">