Édition d'écoles et réglages généraux.

This commit is contained in:
Hugo LEVY-FALK 2018-02-22 20:55:10 +01:00
parent 2dd816b850
commit 8cdef202c7
3 changed files with 35 additions and 25 deletions

View file

@ -3,11 +3,9 @@
<h1>Page d'administration du site</h1>
<h2>Liste des catégories</h2>
<a class="btn btn-success btn-sm" role="button" href="{% url 'content:category-new' %}">
<i class="fas fa-plus"></i>
<i class="glyphicon glyphicon-plus"></i>
Créer une nouvelle catégorie
</a>
<br/>
<br/>
<table class="table table-striped">
<tr>
<th>Nom de la catégorie</th>
@ -19,11 +17,11 @@
<td><a href="{{c.get_absolute_url}}">{{c.name}}</a></td>
<td>{{c.content_set.count}}</td>
<td><a class="btn btn-outline-primary btn-sm" href="{% url "content:category-edit" c.pk %}">
<i class="fas fa-edit"></i>
<!--<i class="glyphicon glyphicon-edit"></i>-->
Éditer
</a>
<a class="btn btn-outline-danger btn-sm" title="Supprimer" href="{% url "content:category-delete" c.pk %}">
<i class="fas fa-trash-alt"></i>
<!--<i class="glyphicon glyphicon-trash"></i>-->
Supprimer
</a>
</td>
@ -34,11 +32,9 @@
<h2>Écoles</h2>
<a class="btn btn-success btn-sm" role="button" href="{% url 'users:new-school' %}">
<i class="fas fa-plus"></i>
<i class="glyphicon glyphicon-plus"></i>
Inscrire une nouvelle école
</a>
<br/>
<br/>
<table class="table table-striped">
<tr>
<th>Nom</th>
@ -48,13 +44,12 @@
<tr>
<th>{{school.group.name}}</th>
<td>{{school.group.user_set.count}}</td>
<td><a class="btn btn-outline-primary btn-sm" href="{% url "users:edit-school" pk=school.pk%}">
<i class="fas fa-edit"></i>
<td><a class="btn btn-primary btn-sm" href="{% url "users:edit-school" pk=school.pk%}">
<i class="glyphicon glyphicon-edit"></i>
Éditer
</a>
<a class="btn btn-outline-danger btn-sm" title="Supprimer" href="">
<i class="fas fa-trash-alt"></i>
Supprimer
<a class="btn btn-danger btn-sm" title="Supprimer" href="">
<i class="glyphicon glyphicon-trash"></i>
</a>
</td>
</tr>
@ -62,12 +57,10 @@
</table>
<h2>Réglages</h2>
<h3>Réglages du site</h3>
<a class="btn btn-primary btn-sm" href="">
<i class="fas fa-edit"></i>
<a class="btn btn-primary btn-sm" href="{% url 'settings:site-settings' %}">
<i class="glyphicon glyphicon-edit"></i>
Éditer
</a>
<br/>
<br/>
<table class="table table-striped">
<tr>
<th>Upload</th>
@ -85,13 +78,11 @@
</tr>
</table>
<h3>Réglages du contenu</h3>
<h3>Réglage du contenu</h3>
<a class="btn btn-primary btn-sm" href="">
<i class="fas fa-edit"></i>
<i class="glyphicon glyphicon-edit"></i>
Éditer
</a>
<br/>
<br/>
<table class="table table-striped">
<tr>
<th>URL du FTP</th>

View file

@ -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'
),
]

View file

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