poulpe/users/views.py

18 lines
646 B
Python
Raw Normal View History

2017-02-21 16:56:34 +01:00
from .forms import CreateUserForm
2017-02-18 01:45:22 +01:00
from django.views.generic.edit import CreateView
from django.contrib.messages.views import SuccessMessageMixin
from django.core.urlresolvers import reverse_lazy
2017-02-21 17:48:56 +01:00
2017-02-18 01:45:22 +01:00
class CreateUser(SuccessMessageMixin, CreateView):
template_name = 'users/user_form.html'
2017-02-21 17:48:56 +01:00
form_class = CreateUserForm
success_url = reverse_lazy('shared:home')
2017-02-18 01:45:22 +01:00
success_message = "Votre compte utilisateur a été correctement créé !"
2017-02-21 17:48:56 +01:00
2017-02-18 01:45:22 +01:00
def get_context_data(self, **kwargs):
2017-04-26 04:08:25 +02:00
ctx = super().get_context_data(**kwargs)
2017-02-21 17:48:56 +01:00
ctx['button'] = 'Créer'
ctx['page_title'] = "Création d'utilisateur"
2017-02-18 01:45:22 +01:00
return ctx