mixing providing organization into context and resolving manage page url

This commit is contained in:
Serghei Mihai 2015-04-28 10:59:41 +02:00
parent efabc3eaf7
commit c98c7b826e
1 changed files with 16 additions and 0 deletions

View File

@ -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'