Ejemplo n.º 1
0
    def test_has_multiple_permissions(self):
        user = User.objects.create(
            username = '******',
            email = '*****@*****.**',
            is_active = True,
            is_staff = False,
            is_superuser = False,
        )

        project = Project.objects.create(name='test1', description='test1', owner=user, slug='test1')
        role = perms.get_role('developer')

        pur = ProjectUserRole.objects.create(
            project = project,
            user = user,
            role = role,
        )
        
        self.assertTrue(perms.has_perms(user, project, [
            ('project', 'view'),
            ('milestone', 'view'),
            ('userstory', 'view'),
        ]))
Ejemplo n.º 2
0
 def check_role(self, user, project, perms, exception=PermissionDeniedException):
     ok = permissions.has_perms(user, project, perms)
     if exception is not None and not ok:
         raise exception()
     return ok
Ejemplo n.º 3
0
def check_role(context, loc, perms):
    project, user, perms = context["project"], context["user"], perms.split(",")
    return permissions.has_perms(user, project, (loc, perms))