Esempio n. 1
0
    def getQR(self, invitation):
        """
        Get a link to an invitation, either as a url string or as a QR code.
        """
        import qrcode
        from girderformindlogger.api.rest import getApiUrl

        try:
            apiUrl = getApiUrl()
        except GirderException:
            import cherrypy
            from girderformindlogger.utiltiy import config

            apiUrl = "/".join([
                cherrypy.url(),
                config.getConfig()['server']['api_root']
            ])

        apiUrl = "?".join([
            "/".join([
                apiUrl,
                'invitation',
                str(invitation['_id'])
            ]),
            'fullHTML=true'
        ])

        img = qrcode.make(apiUrl)
        return(img.show(title=apiUrl))
Esempio n. 2
0
    def getUrl(cls, state):
        clientId = Setting().get(PluginSettings.BOX_CLIENT_ID)

        if not clientId:
            raise Exception('No Box client ID setting is present.')

        callbackUrl = '/'.join((getApiUrl(), 'oauth', 'box', 'callback'))

        query = urllib.parse.urlencode({
            'response_type': 'code',
            'client_id': clientId,
            'redirect_uri': callbackUrl,
            'state': state,
        })
        return '%s?%s' % (cls._AUTH_URL, query)
Esempio n. 3
0
    def getUrl(cls, state):
        clientId = Setting().get(PluginSettings.GITHUB_CLIENT_ID)

        if not clientId:
            raise Exception('No GitHub client ID setting is present.')

        callbackUrl = '/'.join((getApiUrl(), 'oauth', 'github', 'callback'))

        query = urllib.parse.urlencode({
            'client_id': clientId,
            'redirect_uri': callbackUrl,
            'state': state,
            'scope': ','.join(cls._AUTH_SCOPES)
        })
        return '%s?%s' % (cls._AUTH_URL, query)
Esempio n. 4
0
    def getContext(self):
        """
        Get a list of folders with given search parameters. Currently accepted
        search modes are:

        1. Searching by parentId and parentType, with optional additional
           filtering by the name field (exact match) or using full text search
           within a single parent folder. Pass a "name" parameter or "text"
           parameter to invoke these additional filters.
        2. Searching with full text search across all folders in the system.
           Simply pass a "text" parameter for this mode.
        """
        context = FolderModel().findOne({
            'name': 'JSON-LD',
            'parentCollection': 'collection',
            'parentId': CollectionModel().findOne({
                'name': 'Context'
            }).get('_id')
        })
        if context:
            return (context.get('meta', {}))
        user = self.getCurrentUser()
        context = FolderModel().setMetadata(
            folder=FolderModel().createFolder(
                parent=CollectionModel().createCollection(
                    name="Context",
                    creator=user,
                    public=True,
                    reuseExisting=True
                ),
                name="JSON-LD",
                parentType='collection',
                public=True,
                creator=user,
                reuseExisting=True
            ),
            metadata={
                "@context": {
                    "@language": "en-US",
                    "@base": rest.getApiUrl(),
                    "reprolib": REPROLIB_CANONICAL,
                    "http://schema.org/url": {
                        "@type": "@id"
                    }
                }
            }
        )
        return (context.get('meta', {}))
Esempio n. 5
0
    def getUrl(cls, state):
        clientId = Setting().get(PluginSettings.LINKEDIN_CLIENT_ID)

        if not clientId:
            raise Exception('No LinkedIn client ID setting is present.')

        callbackUrl = '/'.join((getApiUrl(), 'oauth', 'linkedin', 'callback'))

        query = urllib.parse.urlencode({
            'response_type': 'code',
            'client_id': clientId,
            'redirect_uri': callbackUrl,
            'state': state,
            'scope': ' '.join(cls._AUTH_SCOPES)
        })
        return '?'.join((cls._AUTH_URL, query))
Esempio n. 6
0
    def getUrl(cls, state):
        clientId = Setting().get(PluginSettings.GOOGLE_CLIENT_ID)

        if not clientId:
            raise Exception('No Google client ID setting is present.')

        callbackUrl = '/'.join((getApiUrl(), 'oauth', 'google', 'callback'))

        query = urllib.parse.urlencode({
            'response_type': 'code',
            'access_type': 'online',
            'client_id': clientId,
            'redirect_uri': callbackUrl,
            'state': state,
            'scope': ' '.join(cls._AUTH_SCOPES)
        })
        return '%s?%s' % (cls._AUTH_URL, query)