Révision 7b499930
Ajouté par Serghei Mihai (congés, retour 15/05) il y a environ 9 ans
uauth/organization/views.py | ||
---|---|---|
1 | 1 |
from django.utils.translation import ugettext as _ |
2 | 2 |
from django.core.urlresolvers import reverse_lazy |
3 |
from django.http import HttpResponseRedirect |
|
3 | 4 |
|
4 | 5 |
from django.views.generic.base import TemplateView |
5 | 6 |
from django.views.generic.list import ListView |
6 |
from django.views.generic.edit import FormView |
|
7 |
from django.views.generic.edit import FormView, UpdateView |
|
8 |
from django.views.generic import DetailView |
|
7 | 9 |
from django.contrib import messages |
8 | 10 |
|
9 | 11 |
from django_tables2 import RequestConfig |
10 | 12 |
|
11 | 13 |
from .utils import create_user |
12 | 14 |
from .models import LocalAccount, Organization |
13 |
from .forms import LocalAccountCreateForm |
|
15 |
from .forms import LocalAccountCreateForm, LocalAccountForm
|
|
14 | 16 |
from .tables import AccountTable |
15 | 17 |
|
16 | 18 |
|
... | ... | |
75 | 77 |
return super(UsersCreateView, self).form_valid(form) |
76 | 78 |
|
77 | 79 |
create_users = UsersCreateView.as_view() |
80 |
|
|
81 |
|
|
82 |
class ShowUserView(OrganizationMixin, DetailView): |
|
83 |
model = LocalAccount |
|
84 |
template_name = 'organization/view_user.html' |
|
85 |
|
|
86 |
view_user = ShowUserView.as_view() |
|
87 |
|
|
88 |
|
|
89 |
class UserEditView(OrganizationMixin, UpdateView): |
|
90 |
template_name = 'organization/edit_user.html' |
|
91 |
model = LocalAccount |
|
92 |
form_class = LocalAccountForm |
|
93 |
|
|
94 |
def form_valid(self, form): |
|
95 |
username = self.object.username |
|
96 |
if 'delete' in self.request.POST: |
|
97 |
self.object.delete() |
|
98 |
messages.info(self.request, _('Account "%s" successfully deleted' % username)) |
|
99 |
return HttpResponseRedirect(self.get_success_url()) |
|
100 |
else: |
|
101 |
messages.info(self.request, _('Account "%s" successfully updated' % username)) |
|
102 |
return super(UserEditView, self).form_valid(form) |
|
103 |
|
|
104 |
edit_user = UserEditView.as_view() |
Formats disponibles : Unified diff
user credentials and edit views(#7065)