How to use the girder.constants.AccessType function in girder

To help you get started, we’ve selected a few girder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github girder / girder / tests / base.py View on Github external
def assertAccessDenied(self, response, level, modelName, user=None):
        if level == AccessType.READ:
            ls = 'Read'
        elif level == AccessType.WRITE:
            ls = 'Write'
        else:
            ls = 'Admin'

        if user is None:
            self.assertStatus(response, 401)
        else:
            self.assertStatus(response, 403)

        self.assertEqual('%s access denied for %s.' % (ls, modelName),
                         response.json['message'])
github Kitware / HPCCloud / server / hpccloud / hpccloud_plugin / projects.py View on Github external
                    model='project', plugin='hpccloud', level=AccessType.READ)
    )
    @access.user
    def get_access(self, project):
        return project.get('access', {'groups': [], 'users': []})
github Kitware / minerva / server / rest / dataset.py View on Github external
    @loadmodel(model='item', level=AccessType.READ)
    def getDataset(self, item, params):
        meta = item['meta']
        if 'minerva' in meta:
            return meta['minerva']
        else:
            return {}
    getDataset.description = (
github DigitalSlideArchive / HistomicsTK / server / image_browse_resource.py View on Github external
def getAdjacentImages(self, currentImage):
        folderModel = Folder()
        folder = folderModel.load(
            currentImage['folderId'], user=self.getCurrentUser(), level=AccessType.READ)
        allImages = [item for item in folderModel.childItems(folder) if _isLargeImageItem(item)]
        try:
            index = allImages.index(currentImage)
        except ValueError:
            raise RestException('Id is not an image', 404)

        return {
            'previous': allImages[index - 1],
            'next': allImages[(index + 1) % len(allImages)]
        }
github Kitware / minerva / girder / api / v1 / resource.py View on Github external
def search(self, params):
        self.requireParams(('q', 'types'), params)

        mode = params.get('mode', 'text')
        level = AccessType.validate(params.get('level', AccessType.READ))
        user = self.getCurrentUser()

        limit = int(params.get('limit', 10))
        offset = int(params.get('offset', 0))

        if mode == 'text':
            method = 'textSearch'
        elif mode == 'prefix':
            method = 'prefixSearch'
        else:
            raise RestException(
                'The search mode must be either "text" or "prefix".')

        try:
            types = json.loads(params['types'])
        except ValueError:
github girder / girder / girder / models / group.py View on Github external
def initialize(self):
        self.name = 'group'
        self.ensureIndices(['lowerName'])
        self.ensureTextIndex({
            'name': 10,
            'description': 1
        })

        self.exposeFields(level=AccessType.READ, fields=(
            '_id', 'name', 'public', 'description', 'created', 'updated',
            'addAllowed', '_addToGroupPolicy'))

        events.bind('model.group.save.created',
                    CoreEventHandler.GROUP_CREATOR_ACCESS,
                    self._grantCreatorAccess)
github girder / girder / girder / api / v1 / resource.py View on Github external
def search(self, q, mode, types, level, limit, offset):
        """
        Perform a search using one of the registered search modes.
        """
        level = AccessType.validate(level)
        user = self.getCurrentUser()
        handler = getSearchModeHandler(mode)
        if handler is None:
            raise RestException('Search mode handler %r not found.' % mode)
        results = handler(
            query=q,
            types=types,
            user=user,
            limit=limit,
            offset=offset,
            level=level
        )
        return results
github girder / girder / girder / api / v1 / file.py View on Github external
                    level=AccessType.WRITE, paramType='formData', model=Item)
    )
    def copy(self, file, item):
        return self._model.copyFile(file, self.getCurrentUser(), item=item)
github girder / large_image / girder_annotation / girder_large_image_annotation / models / annotation.py View on Github external
([
                ('itemId', SortDir.ASCENDING),
                ('_active', SortDir.ASCENDING),
            ], {}),
            ([
                ('_annotationId', SortDir.ASCENDING),
                ('_version', SortDir.DESCENDING),
            ], {}),
            'updated',
        ])
        self.ensureTextIndex({
            'annotation.name': 10,
            'annotation.description': 1,
        })

        self.exposeFields(AccessType.READ, (
            'annotation', '_version', '_elementQuery', '_active',
        ) + self.baseFields)
        events.bind('model.item.remove', 'large_image_annotation', self._onItemRemove)
        events.bind('model.item.copy.prepare', 'large_image_annotation', self._prepareCopyItem)
        events.bind('model.item.copy.after', 'large_image_annotation', self._handleCopyItem)

        self._historyEnabled = Setting().get(
            constants.PluginSettings.LARGE_IMAGE_ANNOTATION_HISTORY)
        # Listen for changes to our relevant settings
        events.bind('model.setting.save.after', 'large_image_annotation', self._onSettingChange)
        events.bind('model.setting.remove', 'large_image_annotation', self._onSettingChange)
github DigitalSlideArchive / digital_slide_archive / server / rest / tcga.py View on Github external
    @access.admin
    @loadmodel(model='slide', plugin='digital_slide_archive',
               level=AccessType.WRITE)
    @describeRoute(
        Description('Remove a slide')
        .param('id', 'The id of the slide', paramType='path')
    )
    def deleteSlide(self, slide, params):
        return self.model('slide', 'digital_slide_archive').removeTCGA(slide)