def post(self, *args, **kwargs): if getattr(settings, 'EXTRACT_ASYNC', None): criteria = _get_request_data(self.request)['criteria'] extract_id = async_extract( self.request.user, json.loads(criteria) ) return _build_json_response({'extract_id': extract_id}) query = queries.SearchBackend( self.request.user, json.loads(self.request.POST['criteria']) ) episodes = query.get_episodes() fname = zip_archive(episodes, query.description(), self.request.user) resp = HttpResponse(open(fname, 'rb').read()) disp = 'attachment; filename="{0}extract{1}.zip"'.format( settings.OPAL_BRAND_NAME, datetime.datetime.now().isoformat()) resp['Content-Disposition'] = disp return resp
def post(self, *args, **kwargs): if getattr(settings, 'EXTRACT_ASYNC', None): criteria = _get_request_data(self.request)['criteria'] extract_id = async_extract(self.request.user, json.loads(criteria)) return json_response({'extract_id': extract_id}) query = queries.create_query(self.request.user, json.loads(self.request.POST['criteria'])) episodes = query.get_episodes() fname = zip_archive(episodes, query.description(), self.request.user) with open(fname, 'rb') as download: content = download.read() resp = HttpResponse(content) disp = 'attachment; filename="{0}extract{1}.zip"'.format( settings.OPAL_BRAND_NAME, datetime.datetime.now().isoformat()) resp['Content-Disposition'] = disp return resp
def test_async(self, delay): extract.async_extract(self.user, 'THIS') delay.assert_called_with(self.user, 'THIS')
def test_async(self, delay): extract.async_extract(self.user, 'THIS') delay.assert_called_with(self.user, 'THIS')