Édition d'écoles.
This commit is contained in:
parent
4da81b99a0
commit
543ca0611b
3 changed files with 23 additions and 4 deletions
|
@ -43,7 +43,7 @@
|
||||||
<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-primary btn-sm" href="">
|
<td><a class="btn btn-primary btn-sm" href="{% url "users:edit-school" pk=school.pk%}">
|
||||||
<i class="glyphicon glyphicon-edit"></i>
|
<i class="glyphicon glyphicon-edit"></i>
|
||||||
Éditer
|
Éditer
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -3,6 +3,7 @@ from .views import (
|
||||||
CreateUser,
|
CreateUser,
|
||||||
CreateUserProfile,
|
CreateUserProfile,
|
||||||
CreateSchool,
|
CreateSchool,
|
||||||
|
EditSchool,
|
||||||
)
|
)
|
||||||
|
|
||||||
app_name = 'users'
|
app_name = 'users'
|
||||||
|
@ -22,4 +23,9 @@ urlpatterns = [
|
||||||
CreateSchool.as_view(),
|
CreateSchool.as_view(),
|
||||||
name='new-school'
|
name='new-school'
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
'school/<int:pk>/edit',
|
||||||
|
EditSchool.as_view(),
|
||||||
|
name='edit-school'
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from django.views.generic import CreateView
|
from django.views.generic import CreateView, UpdateView
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ class CreateUserProfile(CreateView):
|
||||||
|
|
||||||
class CreateSchool(CreateView):
|
class CreateSchool(CreateView):
|
||||||
model = Group
|
model = Group
|
||||||
fields = '__all__'
|
fields = ['name']
|
||||||
template_name = 'edit.html'
|
template_name = 'edit.html'
|
||||||
success_url = reverse_lazy('home')
|
success_url = reverse_lazy('settings:index')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
@ -66,3 +66,16 @@ class CreateSchool(CreateView):
|
||||||
profile.group = form.instance
|
profile.group = form.instance
|
||||||
profile.save()
|
profile.save()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
class EditSchool(UpdateView):
|
||||||
|
model = Group
|
||||||
|
fields = ['name']
|
||||||
|
template_name = 'edit.html'
|
||||||
|
success_url = reverse_lazy('settings:index')
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['title'] = "Édition de l'école"
|
||||||
|
context['validate'] = "Modifier"
|
||||||
|
return context
|
||||||
|
|
Loading…
Reference in a new issue