diff --git a/uauth/organization/views.py b/uauth/organization/views.py index 4f90f16..61bb002 100644 --- a/uauth/organization/views.py +++ b/uauth/organization/views.py @@ -1,5 +1,21 @@ +from django.core.urlresolvers import reverse_lazy from django.views.generic.base import TemplateView + +class OrganizationMixin(object): + + def get_queryset(self): + qs = super(OrganizationMixin, self).get_queryset() + return qs.filter(organization__slug=self.kwargs['organization_slug']) + + def get_success_url(self): + return reverse_lazy('manage-users', kwargs={'organization_slug': self.kwargs['organization_slug']}) + + def get_context_data(self, *args, **kwargs): + ctx = super(OrganizationMixin, self).get_context_data(*args, **kwargs) + ctx['organization'] = Organization.objects.get(slug=self.kwargs['organization_slug']) + return ctx + class ManageView(TemplateView): template_name = 'organization/manage.html'