def export_all_form_metadata_async(req, domain): datespan = req.datespan if req.GET.get("startdate") and req.GET.get("enddate") else None group_id = req.GET.get("group") ufilter = UserTypeFilter.get_user_filter(req)[0] users = util.get_all_users_by_domain( domain=domain, group=group_id, user_filter=ufilter, simplified=True, include_inactive=True ) user_ids = filter(None, [u["user_id"] for u in users]) format = req.GET.get("format", Format.XLS_2007) filename = "%s_forms" % domain download = DownloadBase() download.set_task(create_metadata_export.delay( download.download_id, domain, format=format, filename=filename, datespan=datespan, user_ids=user_ids, )) return download.get_start_response()
def export_all_form_metadata_async(req, domain): datespan = req.datespan if req.GET.get("startdate") and req.GET.get( "enddate") else None group_id = req.GET.get("group") ufilter = UserTypeFilter.get_user_filter(req)[0] users = list( util.get_all_users_by_domain(domain=domain, group=group_id, user_filter=ufilter, simplified=True)) user_ids = filter(None, [u["user_id"] for u in users]) format = req.GET.get("format", Format.XLS_2007) filename = "%s_forms" % domain download = DownloadBase() download.set_task( create_metadata_export.delay( download.download_id, domain, format=format, filename=filename, datespan=datespan, user_ids=user_ids, )) return download.get_start_response()
def get(self, request, *args, **kwargs): assert self.include_multimedia_files or self.include_index_files error_response = self.check_before_zipping() if error_response: return error_response message = request.GET['message'] if 'message' in request.GET else None download = DownloadBase(message=message) build_profile_id = None if domain_has_privilege(request.domain, privileges.BUILD_PROFILES): build_profile_id = request.GET.get('profile') download_targeted_version = request.GET.get( 'download_targeted_version') == 'true' download.set_task( build_application_zip.delay( include_multimedia_files=self.include_multimedia_files, include_index_files=self.include_index_files, domain=self.app.domain, app_id=self.app.id, download_id=download.download_id, compress_zip=self.compress_zip, filename=self.zip_name, build_profile_id=build_profile_id, download_targeted_version=download_targeted_version, )) return download.get_start_response()
def prepare_export(self, export_tags, export_filter): self.generate_bulk_files(export_tags, export_filter) download = DownloadBase() couchexport.tasks.bulk_export_async.delay(self, download.download_id, domain=self.domain) return download.get_start_response()
def export_data_async(self, format=None, **kwargs): format = format or self.default_format download = DownloadBase() download.set_task( couchexport.tasks.export_async.delay(self, download.download_id, format=format, **kwargs)) return download.get_start_response()
def prepare_export(self, export_tags, export_filter): self.generate_bulk_files(export_tags, export_filter) download = DownloadBase() couchexport.tasks.bulk_export_async.delay( self, download.download_id, domain=self.domain ) return download.get_start_response()
def export_data_async(self, format=None, **kwargs): format = format or self.default_format download = DownloadBase() download.set_task(couchexport.tasks.export_async.delay( self, download.download_id, format=format, **kwargs )) return download.get_start_response()
def download_item_lists(request, domain): """Asynchronously serve excel download for edit_lookup_tables """ download = DownloadBase() download.set_task(fixture_download_async.delay( prepare_fixture_download, table_ids=request.GET.getlist("table_id"), domain=domain, download_id=download.download_id, )) return download.get_start_response()
def export_all_form_metadata_async(req, domain): format = req.GET.get("format", Format.XLS_2007) filename = "%s_forms" % domain download = DownloadBase() download.set_task(create_metadata_export.delay( download.download_id, domain, format=format, filename=filename, )) return download.get_start_response()
def download_item_lists(request, domain): """Asynchronously serve excel download for edit_lookup_tables """ download = DownloadBase() download.set_task(fixture_download_async.delay( prepare_fixture_download, table_ids=request.POST.getlist("table_ids[]", []), domain=domain, download_id=download.download_id, )) return download.get_start_response()
def generate_payload(payload_func): if async: download = DownloadBase() a_task = prepare_download.delay(download.download_id, payload_func, content_disposition, mimetype) download.set_task(a_task) return download.get_start_response() else: payload = payload_func() response = HttpResponse(payload) response["Content-Type"] = mimetype response["Content-Disposition"] = content_disposition return response
def generate_payload(payload_func): if async: download = DownloadBase() a_task = prepare_download.delay(download.download_id, payload_func, content_disposition, mimetype) download.set_task(a_task) return download.get_start_response() else: payload = payload_func() response = HttpResponse(payload) response['Content-Type'] = mimetype response['Content-Disposition'] = content_disposition return response
def get(self, request, *args, **kwargs): assert self.include_multimedia_files or self.include_index_files error_response = self.check_before_zipping() if error_response: return error_response download = DownloadBase() download.set_task(build_application_zip.delay( include_multimedia_files=self.include_multimedia_files, include_index_files=self.include_index_files, app=self.app, download_id=download.download_id, compress_zip=self.compress_zip, filename=self.zip_name) ) return download.get_start_response()
def get(self, request, *args, **kwargs): assert self.include_multimedia_files or self.include_index_files error_response = self.check_before_zipping() if error_response: return error_response download = DownloadBase() download.set_task( build_application_zip.delay( include_multimedia_files=self.include_multimedia_files, include_index_files=self.include_index_files, app=self.app, download_id=download.download_id, compress_zip=self.compress_zip, filename=self.zip_name)) return download.get_start_response()
def get(self, request, *args, **kwargs): assert self.include_multimedia_files or self.include_index_files error_response = self.check_before_zipping() if error_response: return error_response message = request.GET['message'] if 'message' in request.GET else None download = DownloadBase(message=message) build_profile_id = None if domain_has_privilege(request.domain, privileges.BUILD_PROFILES): build_profile_id = request.GET.get('profile') download.set_task(build_application_zip.delay( include_multimedia_files=self.include_multimedia_files, include_index_files=self.include_index_files, app=self.app, download_id=download.download_id, compress_zip=self.compress_zip, filename=self.zip_name, build_profile_id=build_profile_id) ) return download.get_start_response()