Beispiel #1
0
    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())
Beispiel #2
0
    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())