コード例 #1
0
def update_assessment_permissions(apps, schema_editor):
    ProjectRole = apps.get_model('project', 'ProjectRole')

    admin_role = ProjectRole.objects.filter(is_creator_role=True)
    normal_role = ProjectRole.objects.filter(is_default_role=True)

    admin_role.update(assessment_permissions=get_project_permissions_value(
        'assessment', '__all__'))
    normal_role.update(assessment_permissions=get_project_permissions_value(
        'assessment', '__all__'))
コード例 #2
0
 def setUp(self):
     super().setUp()
     self.no_entry_creation_role = ProjectRole.objects.create(
         title='No Lead Creation Role',
         entry_permissions=0,
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         setup_permissions=get_project_permissions_value(
             'setup', '__all__'),
         export_permissions=get_project_permissions_value(
             'export', '__all__'),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
     )
     self.entry_creation_role = ProjectRole.objects.create(
         title='Lead Creation Role',
         entry_permissions=get_project_permissions_value(
             'entry', ['create']),
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         setup_permissions=get_project_permissions_value(
             'setup', '__all__'),
         export_permissions=get_project_permissions_value(
             'export', '__all__'),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
     )
コード例 #3
0
def create_base_roles(apps, schema_editor):
    ProjectRole = apps.get_model('project', 'ProjectRole')
    # Admin Role
    ProjectRole.objects.create(
            title='Admin',
            lead_permissions=get_project_permissions_value('lead', '__all__'),
            entry_permissions=get_project_permissions_value(
                'entry', '__all__'),
            setup_permissions=get_project_permissions_value(
                'setup', '__all__'),
            export_permissions=get_project_permissions_value(
                'export', '__all__'),
            is_creator_role=True
        )
    # Default role
    ProjectRole.objects.create(
        title='Analyst',
        lead_permissions=get_project_permissions_value(
            'lead', '__all__'),
        entry_permissions=get_project_permissions_value(
            'entry', '__all__'),
        setup_permissions=get_project_permissions_value('setup', []),
        export_permissions=get_project_permissions_value(
            'export', ['create']),
        is_default_role=True
    )
コード例 #4
0
 def _create_role(title, _type, level=1, is_default_role=False):
     # NOTE: Graphql endpoints will use static permission (Will remove dynamic permission in future)
     # TODO: Migrate current dynamic permission to static ones.
     return ProjectRole.objects.create(
         title=title,
         lead_permissions=get_project_permissions_value(
             'lead', '__all__'),
         entry_permissions=get_project_permissions_value(
             'entry', '__all__'),
         setup_permissions=get_project_permissions_value(
             'setup', '__all__'),
         export_permissions=get_project_permissions_value(
             'export', '__all__'),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
         is_creator_role=False,
         level=level,
         is_default_role=is_default_role,
         type=_type,
     )
コード例 #5
0
ファイル: test_permissions.py プロジェクト: the-deep/server
 def setUp(self):
     super().setUp()
     common_role_attrs = {
         'entry_permissions':
         get_project_permissions_value('entry', '__all__'),
         'setup_permissions':
         get_project_permissions_value('setup', '__all__'),
         'export_permissions':
         get_project_permissions_value('export', '__all__'),
         'assessment_permissions':
         get_project_permissions_value('assessment', '__all__'),
     }
     self.no_lead_creation_role = ProjectRole.objects.create(
         title='No Lead Creation Role',
         lead_permissions=0,
         **common_role_attrs)
     self.lead_creation_role = ProjectRole.objects.create(
         title='Lead Creation Role',
         lead_permissions=get_project_permissions_value('lead', ['create']),
         **common_role_attrs)
     self.lead_view_clone_role = ProjectRole.objects.create(
         title='Lead View Role',
         lead_permissions=get_project_permissions_value(
             'lead', ['view', 'create']),
         **common_role_attrs)
     self.author = self.source = self.create_organization()
コード例 #6
0
ファイル: test_case.py プロジェクト: timilsinabishal/server
 def create_project_roles(self):
     # Remove roles if already exist. Right now, we just have global roles
     ProjectRole.objects.all().delete()
     # Creator role
     self.admin_role = ProjectRole.objects.create(
         title='Admin',
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         entry_permissions=get_project_permissions_value(
             'entry', '__all__'),
         setup_permissions=get_project_permissions_value(
             'setup', '__all__'),
         export_permissions=get_project_permissions_value(
             'export', '__all__'),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
         is_creator_role=True)
     # Default role
     self.normal_role = ProjectRole.objects.create(
         title='Analyst',
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         entry_permissions=get_project_permissions_value(
             'entry', '__all__'),
         setup_permissions=get_project_permissions_value('setup', []),
         export_permissions=get_project_permissions_value(
             'export', ['create']),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
         is_default_role=True)
     self.view_only_role = ProjectRole.objects.create(
         title='ViewOnly',
         lead_permissions=get_project_permissions_value('lead', ['view']),
         entry_permissions=get_project_permissions_value('entry', ['view']),
         setup_permissions=get_project_permissions_value('setup', []),
         export_permissions=get_project_permissions_value('export', []),
         assessment_permissions=get_project_permissions_value(
             'assessment', ['view']),
     )
コード例 #7
0
 def create_project_roles(self):
     # Remove roles if already exist. Right now, we just have global roles
     ProjectRole.objects.all().delete()
     # Creator role
     self.admin_role = ProjectRole.objects.create(
         title='Clairvoyant One',
         type=ProjectRole.Type.PROJECT_OWNER,
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         entry_permissions=get_project_permissions_value(
             'entry', '__all__'),
         setup_permissions=get_project_permissions_value(
             'setup', '__all__'),
         export_permissions=get_project_permissions_value(
             'export', '__all__'),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
         is_creator_role=True,
         level=1,
     )
     # Smaller admin role
     self.smaller_admin_role = ProjectRole.objects.create(
         title='Admin',
         type=ProjectRole.Type.ADMIN,
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         entry_permissions=get_project_permissions_value(
             'entry', '__all__'),
         setup_permissions=get_project_permissions_value(
             'setup', ['modify']),
         export_permissions=get_project_permissions_value(
             'export', '__all__'),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
         is_creator_role=True,
         level=100,
     )
     # Default role
     self.normal_role = ProjectRole.objects.create(
         title='Analyst',
         type=ProjectRole.Type.MEMBER,
         lead_permissions=get_project_permissions_value('lead', '__all__'),
         entry_permissions=get_project_permissions_value(
             'entry', '__all__'),
         setup_permissions=get_project_permissions_value('setup', []),
         export_permissions=get_project_permissions_value(
             'export', ['create']),
         assessment_permissions=get_project_permissions_value(
             'assessment', '__all__'),
         is_default_role=True,
         level=100,
     )
     self.view_only_role = ProjectRole.objects.create(
         title='Viewer',
         type=ProjectRole.Type.READER,
         lead_permissions=get_project_permissions_value('lead', ['view']),
         entry_permissions=get_project_permissions_value('entry', ['view']),
         setup_permissions=get_project_permissions_value('setup', []),
         export_permissions=get_project_permissions_value('export', []),
         assessment_permissions=get_project_permissions_value(
             'assessment', ['view']),
     )