|
|
|
@ -1,5 +1,5 @@ |
|
|
|
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.shortcuts import get_object_or_404 |
|
|
|
|
|
|
|
@ -50,9 +50,9 @@ class CreateUserProfile(CreateView): |
|
|
|
|
|
|
|
class CreateSchool(CreateView): |
|
|
|
model = Group |
|
|
|
fields = '__all__' |
|
|
|
fields = ['name'] |
|
|
|
template_name = 'edit.html' |
|
|
|
success_url = reverse_lazy('home') |
|
|
|
success_url = reverse_lazy('settings:index') |
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
context = super().get_context_data(**kwargs) |
|
|
|
@ -66,3 +66,16 @@ class CreateSchool(CreateView): |
|
|
|
profile.group = form.instance |
|
|
|
profile.save() |
|
|
|
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 |
|
|
|
|