Last active
February 2, 2016 03:00
-
-
Save sivabudh/b21446eac86d0fdd854b to your computer and use it in GitHub Desktop.
Good or bad code?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomerPortal(LoginRequiredMixin, UserPassesTestMixin, DetailView): | |
model = Customer | |
template_name = 'bod/customer_portal.html' | |
def test_func(self): | |
user_pk = int(self.kwargs['pk']) | |
user = self.request.user | |
is_customer = user.groups.filter(name='Customer').exists() | |
return is_customer and user.pk == user_pk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment