poulpe/users/views.py

18 lines
662 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-02-21 17:48:56 +01:00
ctx = super(CreateUser, self).get_context_data(**kwargs)
ctx['button'] = 'Créer'
ctx['page_title'] = "Création d'utilisateur"
2017-02-18 01:45:22 +01:00
return ctx