Ejemplo n.º 1
0
    def get(self, request, file_mgr_name, system_id=None, file_path=None):
        """ GET handler """
        offset = int(request.GET.get('offset', 0))
        limit = int(request.GET.get('limit', 100))
        query_string = request.GET.get('query_string')

        if file_mgr_name != ElasticFileManager.NAME or not query_string:
            return HttpResponseBadRequest()

        if system_id is None:
            system_id = ElasticFileManager.DEFAULT_SYSTEM_ID

        fmgr = ElasticFileManager()
        if not request.GET.get('shared', False):

            if system_id == 'designsafe.storage.default':
                listing = fmgr.search(system_id,
                                      request.user.username,
                                      query_string,
                                      offset=offset,
                                      limit=limit)
            elif system_id == 'designsafe.storage.community':
                logger.debug("searching community...")
                listing = fmgr.search_community('designsafe.storage.community',
                                                query_string,
                                                offset=offset,
                                                limit=limit)
        else:
            listing = fmgr.search_shared(system_id,
                                         request.user.username,
                                         query_string,
                                         offset=offset,
                                         limit=limit)

        return JsonResponse(listing)
Ejemplo n.º 2
0
    def get(self, request, file_mgr_name, system_id=None, file_path=None):
        """ GET handler """
        offset = int(request.GET.get('offset', 0))
        limit = int(request.GET.get('limit', 100))
        query_string = request.GET.get('query_string')

        if file_mgr_name != ElasticFileManager.NAME or not query_string:
            return HttpResponseBadRequest()

        if system_id is None:
            system_id = ElasticFileManager.DEFAULT_SYSTEM_ID

        fmgr = ElasticFileManager()
        if not (request.GET.get('shared', False)
                or request.GET.get('projects', False)):
            listing = fmgr.search(system_id,
                                  request.user.username,
                                  query_string,
                                  offset=offset,
                                  limit=limit)
        elif request.GET.get('shared', False):
            listing = fmgr.search_shared(system_id,
                                         request.user.username,
                                         query_string,
                                         offset=offset,
                                         limit=limit)
        elif request.GET.get('projects', False):
            listing = fmgr.search_projects(request.user.username,
                                           query_string,
                                           offset=offset,
                                           limit=limit)

        return JsonResponse(listing)
Ejemplo n.º 3
0
    def get(self, request, file_mgr_name, system_id = None, file_path = None):
        """ GET handler """
        offset = int(request.GET.get('offset', 0))
        limit = int(request.GET.get('limit', 100))
        query_string = request.GET.get('query_string')

        if file_mgr_name != ElasticFileManager.NAME or not query_string:
            return HttpResponseBadRequest()
        
        if system_id is None:
            system_id = ElasticFileManager.DEFAULT_SYSTEM_ID

        fmgr = ElasticFileManager()
        if not request.GET.get('shared', False):
            listing = fmgr.search(system_id, request.user.username, query_string,
                                  offset=offset, limit=limit)
        else:
            listing = fmgr.search_shared(system_id, request.user.username, query_string,
                                         offset=offset, limit=limit)

        return JsonResponse(listing)