summaryrefslogtreecommitdiffstats
path: root/uauth/organization/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'uauth/organization/views.py')
-rw-r--r--uauth/organization/views.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/uauth/organization/views.py b/uauth/organization/views.py
index 3175cd6..adae5e7 100644
--- a/uauth/organization/views.py
+++ b/uauth/organization/views.py
@@ -1,16 +1,18 @@
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse_lazy
+from django.http import HttpResponseRedirect
from django.views.generic.base import TemplateView
from django.views.generic.list import ListView
-from django.views.generic.edit import FormView
+from django.views.generic.edit import FormView, UpdateView
+from django.views.generic import DetailView
from django.contrib import messages
from django_tables2 import RequestConfig
from .utils import create_user
from .models import LocalAccount, Organization
-from .forms import LocalAccountCreateForm
+from .forms import LocalAccountCreateForm, LocalAccountForm
from .tables import AccountTable
@@ -75,3 +77,28 @@ class UsersCreateView(OrganizationMixin, FormView):
return super(UsersCreateView, self).form_valid(form)
create_users = UsersCreateView.as_view()
+
+
+class ShowUserView(OrganizationMixin, DetailView):
+ model = LocalAccount
+ template_name = 'organization/view_user.html'
+
+view_user = ShowUserView.as_view()
+
+
+class UserEditView(OrganizationMixin, UpdateView):
+ template_name = 'organization/edit_user.html'
+ model = LocalAccount
+ form_class = LocalAccountForm
+
+ def form_valid(self, form):
+ username = self.object.username
+ if 'delete' in self.request.POST:
+ self.object.delete()
+ messages.info(self.request, _('Account "%s" successfully deleted' % username))
+ return HttpResponseRedirect(self.get_success_url())
+ else:
+ messages.info(self.request, _('Account "%s" successfully updated' % username))
+ return super(UserEditView, self).form_valid(form)
+
+edit_user = UserEditView.as_view()