예제 #1
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())
예제 #2
0
파일: tests.py 프로젝트: owaisj/portal
 def test_trash_raises(self):
     mock_ac = MagicMock()
     fm = CommunityFileManager(mock_ac)
     with self.assertRaises(ApiException):
         fm.trash()
예제 #3
0
파일: tests.py 프로젝트: owaisj/portal
 def test_requires_auth(self):
     mock_ac = MagicMock()
     fm = CommunityFileManager(mock_ac)
     self.assertEqual(fm.requires_auth, False)
예제 #4
0
파일: tests.py 프로젝트: owaisj/portal
 def test_listing(self, mock_afm):
     mock_ac = MagicMock()
     fm = CommunityFileManager(mock_ac)
     fm.listing('test.system', '/')
     mock_afm.listing.assert_called_with(mock_ac, 'test.system', '/', 0,
                                         100)