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

View file

@ -1,5 +1,5 @@
from django.urls import path from django.urls import path
from .views import SettingsView from .views import SettingsView, EditSiteSettingsView
app_name = 'settings' app_name = 'settings'
urlpatterns = [ urlpatterns = [
@ -8,4 +8,9 @@ urlpatterns = [
SettingsView.as_view(), SettingsView.as_view(),
name='index' 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 content.models import Category
from users.models import SchoolProfile from users.models import SchoolProfile
from .models import ContentSettings, SiteSettings from .models import ContentSettings, SiteSettings
class SettingsView(TemplateView): class SettingsView(TemplateView):
template_name = "settings/settings.html" template_name = "settings/settings.html"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context['categories'] = Category.objects.all() context['categories'] = Category.objects.all()
context['site_settings'],_ = SiteSettings.objects.get_or_create() context['site_settings'], _ = SiteSettings.objects.get_or_create()
context['content_settings'],_ = ContentSettings.objects.get_or_create() context['content_settings'], _ = ContentSettings.objects.get_or_create()
context['schools'] = SchoolProfile.objects.all() context['schools'] = SchoolProfile.objects.all()
context['settings'] = True
return context 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