Python django.contrib.auth.mixins.UserPassesTestMixin() Examples
The following are 30
code examples of django.contrib.auth.mixins.UserPassesTestMixin().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.contrib.auth.mixins
, or try the search function
.
Example #1
Source File: views.py From coldfront with GNU General Public License v3.0 | 10 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('project.can_view_all_projects'): return True project_obj = self.get_object() if project_obj.projectuser_set.filter(user=self.request.user, status__name='Active').exists(): return True messages.error( self.request, 'You do not have permission to view the previous page.') return False
Example #2
Source File: views.py From coldfront with GNU General Public License v3.0 | 6 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_view_all_allocations'): return True pk = self.kwargs.get('pk') allocation_obj = get_object_or_404(Allocation, pk=pk) user_can_access_project = allocation_obj.project.projectuser_set.filter( user=self.request.user, status__name__in=['Active', 'New', ]).exists() user_can_access_allocation = allocation_obj.allocationuser_set.filter( user=self.request.user, status__name__in=['Active', ]).exists() if user_can_access_project and user_can_access_allocation: return True return False
Example #3
Source File: views.py From coldfront with GNU General Public License v3.0 | 6 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404( Project, pk=self.kwargs.get('project_pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error( self.request, 'You do not have permission to create a new allocation.')
Example #4
Source File: views.py From coldfront with GNU General Public License v3.0 | 6 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True allocation_obj = get_object_or_404( Allocation, pk=self.kwargs.get('pk')) if allocation_obj.project.pi == self.request.user: return True if allocation_obj.project.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error( self.request, 'You do not have permission to add users to the allocation.')
Example #5
Source File: views.py From coldfront with GNU General Public License v3.0 | 6 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True allocation_obj = get_object_or_404( Allocation, pk=self.kwargs.get('pk')) if allocation_obj.project.pi == self.request.user: return True if allocation_obj.project.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error( self.request, 'You do not have permission to remove users from allocation.')
Example #6
Source File: views.py From coldfront with GNU General Public License v3.0 | 6 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True allocation_obj = get_object_or_404( Allocation, pk=self.kwargs.get('pk')) if allocation_obj.project.pi == self.request.user: return True if allocation_obj.project.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error( self.request, 'You do not have permission to renew allocation.') return False
Example #7
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_review_allocation_requests'): return True messages.error( self.request, 'You do not have permission to activate a allocation request.')
Example #8
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('grant.can_view_all_grants'): return True messages.error(self.request, 'You do not have permission to view all grants.')
Example #9
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True else: messages.error( self.request, 'You do not have permission to add allocation attributes.')
Example #10
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_review_allocation_requests'): return True messages.error( self.request, 'You do not have permission to review allocation requests.')
Example #11
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True grant_obj = get_object_or_404(Grant, pk=self.kwargs.get('pk')) if grant_obj.project.pi == self.request.user: return True if grant_obj.project.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error(self.request, 'You do not have permission to update grant from this project.')
Example #12
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_review_allocation_requests'): return True messages.error( self.request, 'You do not have permission to deny a allocation request.')
Example #13
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_manage_invoice'): return True messages.error( self.request, 'You do not have permission to manage invoices.') return False
Example #14
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_manage_invoice'): return True
Example #15
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_manage_invoice'): return True
Example #16
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('allocation.can_manage_invoice'): return True
Example #17
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if not ALLOCATION_ACCOUNT_ENABLED: return False elif self.request.user.is_superuser: return True elif self.request.user.userprofile.is_pi: return True else: messages.error( self.request, 'You do not have permission to add allocation attributes.') return False
Example #18
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if not ALLOCATION_ACCOUNT_ENABLED: return False elif self.request.user.is_superuser: return True elif self.request.user.userprofile.is_pi: return True else: messages.error( self.request, 'You do not have permission to manage invoices.') return False
Example #19
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('project.can_review_pending_project_reviews'): return True messages.error( self.request, 'You do not have permission to review pending project reviews.')
Example #20
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True
Example #21
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.userprofile.is_pi: return True
Example #22
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = self.get_object() if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True
Example #23
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True
Example #24
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True
Example #25
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True
Example #26
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True
Example #27
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error( self.request, 'You do not have permissions to review this project.')
Example #28
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404(Project, pk=self.kwargs.get('project_pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True messages.error(self.request, 'You do not have permission to delete grants from this project.')
Example #29
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True if self.request.user.has_perm('project.can_review_pending_project_reviews'): return True messages.error( self.request, 'You do not have permission to send email for a pending project review.')
Example #30
Source File: views.py From coldfront with GNU General Public License v3.0 | 5 votes |
def test_func(self): """ UserPassesTestMixin Tests""" if self.request.user.is_superuser: return True project_obj = get_object_or_404( Project, pk=self.kwargs.get('project_pk')) if project_obj.pi == self.request.user: return True if project_obj.projectuser_set.filter(user=self.request.user, role__name='Manager', status__name='Active').exists(): return True