Esempio n. 1
0
    def get_object(self):
        if self.request.method == 'DELETE':
            Permission.check_user_permissions(
                permissions=(permission_staging_file_delete, ),
                user=self.request.user)

        staging_folder = get_object_or_404(klass=StagingFolderSource,
                                           pk=self.kwargs['staging_folder_pk'])
        return staging_folder.get_file(
            encoded_filename=self.kwargs['encoded_filename'])
Esempio n. 2
0
 def get_form_schema(self, *args, **kwargs):
     self.fields['content_type']['kwargs'][
         'queryset'] = ModelPermission.get_classes(
             as_content_type=True).order_by('model')
     self.fields['permissions']['kwargs']['choices'] = Permission.all(
         as_choices=True)
     return super(GrantAccessAction, self).get_form_schema(*args, **kwargs)
Esempio n. 3
0
    def get_execute_data(self):
        ContentType = apps.get_model(app_label='contenttypes',
                                     model_name='ContentType')

        content_type = ContentType.objects.get(
            pk=self.form_data['content_type'])
        self.obj = content_type.get_object_for_this_type(
            pk=self.form_data['object_id'])
        self.roles = Role.objects.filter(pk__in=self.form_data['roles'])
        self.permissions = [
            Permission.get(pk=permission, class_only=True)
            for permission in self.form_data['permissions']
        ]
Esempio n. 4
0
 def setUp(self):
     super(BaseTestCase, self).setUp()
     Namespace.invalidate_cache_all()
     Permission.invalidate_cache()
Esempio n. 5
0
 def permission_check(user):
     return Permission.check_user_permissions(
         permissions=(permission_users_impersonate, ), user=user)
Esempio n. 6
0
 def get_execute_data(self):
     self.roles = Role.objects.filter(pk__in=self.form_data['roles'])
     self.permissions = [
         Permission.get(pk=permission, class_only=True)
         for permission in self.form_data['permissions']
     ]