Example #1
0
    def get(self, request, file_mgr_name, system_id=None, file_path=''):
        kwargs = {}

        offset = int(request.GET.get('offset', 0))
        limit = int(request.GET.get('limit', 100))
        query_string = request.GET.get('query_string', None)
        type_filters = request.GET.getlist('typeFilters', None)

        if type_filters:
            kwargs['type_filters'] = type_filters

        if not request.user.is_authenticated:
            client = get_user_model().objects.get(
                username='******').agave_oauth.client
        else:
            client = request.user.agave_oauth.client

        if system_id is None:
            system_id = AgaveFileManager.DEFAULT_SYSTEM_ID
        if system_id == AgaveFileManager.DEFAULT_SYSTEM_ID and not file_path:
            file_path = request.user.username
        if system_id == AgaveFileManager.DEFAULT_SYSTEM_ID and \
                (file_path.strip('/') == '$SHARE'):
            file_mgr_name = 'shared'
            kwargs['user_context'] = request.user.username

        fm_cls = FileLookupManager(file_mgr_name)
        fm = fm_cls(agave_client=client)

        if fm.requires_auth and not request.user.is_authenticated:
            return HttpResponseForbidden('Login Required.')
        if query_string:
            fm = SearchLookupManager(file_mgr_name)(request)
        listing = fm.listing(system=system_id,
                             file_path=file_path,
                             offset=offset,
                             limit=limit,
                             **kwargs)
        return JsonResponse(listing, encoder=AgaveJSONEncoder, safe=False)
Example #2
0
 def test_lookup_returns_for_community(self):
     self.assertEqual(SearchLookupManager('community'),
                      CommunityDataSearchManager)
Example #3
0
 def test_lookup_returns_for_published_files(self):
     self.assertEqual(SearchLookupManager('published'),
                      PublishedDataSearchManager)
Example #4
0
 def test_lookup_returns_for_publications(self):
     self.assertEqual(SearchLookupManager('public'),
                      PublicationsSearchManager)
Example #5
0
 def test_lookup_returns_for_private(self):
     self.assertEqual(SearchLookupManager('agave'),
                      PrivateDataSearchManager)
Example #6
0
 def test_lookup_returns_for_shared(self):
     self.assertEqual(SearchLookupManager('shared'),
                      SharedDataSearchManager)