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') logger.debug('offset: %s, limit: %s, query_string: %s' % (str(offset), str(limit), query_string)) if file_mgr_name != PublicElasticFileManager.NAME or not query_string: return HttpResponseBadRequest() if system_id is None: system_id = PublicElasticFileManager.DEFAULT_SYSTEM_ID if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client if system_id == "nees.public" or system_id == "designsafe.storage.published": file_mgr = PublicElasticFileManager(ag) listing = file_mgr.search(system_id, query_string, offset=offset, limit=limit) elif system_id == "designsafe.storage.community": file_mgr = ElasticFileManager() listing = file_mgr.search_community('designsafe.storage.community', query_string, offset=offset, limit=limit) # logger.info(listing) return JsonResponse(listing)
def get(self, request, file_mgr_name, system_id=None, file_path=None): """GET handler.""" if file_mgr_name != PublicElasticFileManager.NAME: return HttpResponseBadRequest() if system_id is None: system_id = PublicElasticFileManager.DEFAULT_SYSTEM_ID file_mgr = PublicElasticFileManager() listing = file_mgr.listing(system_id, file_path) return JsonResponse(listing.to_dict())
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') logger.debug('offset: %s, limit: %s, query_string: %s' % (str(offset), str(limit), query_string)) if file_mgr_name != PublicElasticFileManager.NAME or not query_string: return HttpResponseBadRequest() if system_id is None: system_id = PublicElasticFileManager.DEFAULT_SYSTEM_ID file_mgr = PublicElasticFileManager() listing = file_mgr.search(system_id, query_string, offset=offset, limit=limit) return JsonResponse(listing)
def get(self, request, file_mgr_name, system_id=None, file_path=None): """GET handler.""" if file_mgr_name not in [ PublicElasticFileManager.NAME, 'community', 'published' ]: return HttpResponseBadRequest('Wrong Manager') if file_mgr_name == PublicElasticFileManager.NAME: if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client if system_id is None or (file_path is None or file_path == '/'): system_id = PublicElasticFileManager.DEFAULT_SYSTEM_ID file_mgr = PublicElasticFileManager(ag) elif file_mgr_name == 'community': if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client file_mgr = CommunityFileManager(ag) elif file_mgr_name == 'published': if not request.user.is_authenticated: ag = get_user_model().objects.get( username='******').agave_oauth.client else: ag = request.user.agave_oauth.client file_mgr = PublishedFileManager(ag) offset = int(request.GET.get('offset', 0)) limit = int(request.GET.get('limit', 100)) status = request.GET.get('status', 'published') listing = file_mgr.listing(system_id, file_path, offset=offset, limit=limit, status=status) # logger.debug(listing.to_dict()['children'][0]) return JsonResponse(listing.to_dict())