本文整理汇总了Python中soil.DownloadBase.set_task方法的典型用法代码示例。如果您正苦于以下问题:Python DownloadBase.set_task方法的具体用法?Python DownloadBase.set_task怎么用?Python DownloadBase.set_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soil.DownloadBase
的用法示例。
在下文中一共展示了DownloadBase.set_task方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_form_multimedia
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def prepare_form_multimedia(request, domain):
"""Gets the download_id for the multimedia zip and sends it to the
exportDownloadService in download_export.ng.js to begin polling for the
zip file download.
"""
form_or_case = request.POST.get('form_or_case')
sms_export = json.loads(request.POST.get('sms_export'))
permissions = ExportsPermissionsManager(form_or_case, domain, request.couch_user)
permissions.access_download_export_or_404()
view_helper = DownloadExportViewHelper.get(request, domain, form_or_case, sms_export)
filter_form_data = json.loads(request.POST.get('form_data'))
export_specs = json.loads(request.POST.get('exports'))
try:
filter_form = view_helper.get_filter_form(filter_form_data)
except ExportFormValidationException:
return json_response({
'error': _("Please check that you've submitted all required filters."),
})
download = DownloadBase()
export_object = view_helper.get_export(export_specs[0]['export_id'])
task_kwargs = filter_form.get_multimedia_task_kwargs(export_object, download.download_id, filter_form_data)
from corehq.apps.reports.tasks import build_form_multimedia_zip
download.set_task(build_form_multimedia_zip.delay(**task_kwargs))
return json_response({
'success': True,
'download_id': download.download_id,
})
示例2: export_all_form_metadata_async
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
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()
示例3: toggle_demo_mode
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def toggle_demo_mode(request, domain, user_id):
user = CommCareUser.get_by_user_id(user_id, domain)
demo_mode = request.POST.get('demo_mode', 'no')
demo_mode = True if demo_mode == 'yes' else False
edit_user_url = reverse(EditCommCareUserView.urlname, args=[domain, user_id])
# handle bad POST param
if user.is_demo_user == demo_mode:
warning = _("User is already in Demo mode!") if user.is_demo_user else _("User is not in Demo mode!")
messages.warning(request, warning)
return HttpResponseRedirect(edit_user_url)
if demo_mode:
download = DownloadBase()
res = turn_on_demo_mode_task.delay(user.get_id, domain)
download.set_task(res)
return HttpResponseRedirect(
reverse(
DemoRestoreStatusView.urlname,
args=[domain, download.download_id, user_id]
)
)
else:
from corehq.apps.app_manager.views.utils import unset_practice_mode_configured_apps, \
get_practice_mode_configured_apps
# if the user is being used as practice user on any apps, check/ask for confirmation
apps = get_practice_mode_configured_apps(domain)
confirm_turn_off = True if (request.POST.get('confirm_turn_off', 'no')) == 'yes' else False
if apps and not confirm_turn_off:
return HttpResponseRedirect(reverse(ConfirmTurnOffDemoModeView.urlname, args=[domain, user_id]))
turn_off_demo_mode(user)
unset_practice_mode_configured_apps(domain, user.get_id)
messages.success(request, _("Successfully turned off demo mode!"))
return HttpResponseRedirect(edit_user_url)
示例4: prepare_form_multimedia
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def prepare_form_multimedia(self, in_data):
"""Gets the download_id for the multimedia zip and sends it to the
exportDownloadService in download_export.ng.js to begin polling for the
zip file download.
"""
try:
filter_form_data, export_specs = self._get_form_data_and_specs(in_data)
filter_form = FilterFormExportDownloadForm(
self.domain_object, self.timezone, filter_form_data
)
if not filter_form.is_valid():
raise ExportFormValidationException(
_("Please check that you've submitted all required filters.")
)
download = DownloadBase()
export_object = self.get_export_schema(self.domain, export_specs[0]['export_id'])
task_kwargs = filter_form.get_multimedia_task_kwargs(
export_object, download.download_id
)
from corehq.apps.reports.tasks import build_form_multimedia_zip
download.set_task(build_form_multimedia_zip.delay(**task_kwargs))
except Exception as e:
return format_angular_error(e)
return format_angular_success({
'download_id': download.download_id,
})
示例5: export_data_async
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
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()
示例6: get_download_task
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def get_download_task(self, export_tags, export_filter):
self.generate_bulk_files(export_tags, export_filter)
download = DownloadBase()
download.set_task(couchexport.tasks.bulk_export_async.delay(
self,
download.download_id,
domain=self.domain
))
return download
示例7: export_all_form_metadata_async
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
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()
示例8: download_item_lists
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
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()
示例9: generate_payload
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
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
示例10: download_commcare_users
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def download_commcare_users(request, domain):
form = CommCareUserFilterForm(request.GET, domain=domain)
user_filters = {}
if form.is_valid():
user_filters = form.cleaned_data
else:
return HttpResponseRedirect(
reverse(FilteredUserDownload.urlname, args=[domain]) + "?" + request.GET.urlencode())
download = DownloadBase()
res = bulk_download_users_async.delay(domain, download.download_id, user_filters)
download.set_task(res)
return redirect(DownloadUsersStatusView.urlname, domain, download.download_id)
示例11: excel_commit
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def excel_commit(request, domain):
"""
Step three of three.
This page is submitted with the list of column to
case property mappings for this upload.
The config variable is an ImporterConfig object that
has everything gathered from previous steps, with the
addition of all the field data. See that class for
more information.
"""
config = importer_util.ImporterConfig.from_request(request)
excel_id = request.session.get(EXCEL_SESSION_ID)
excel_ref = DownloadBase.get(excel_id)
spreadsheet = importer_util.get_spreadsheet(excel_ref, config.named_columns)
if not spreadsheet:
return _spreadsheet_expired(request, domain)
if spreadsheet.has_errors:
messages.error(request, _('The session containing the file you '
'uploaded has expired - please upload '
'a new one.'))
return HttpResponseRedirect(base.ImportCases.get_url(domain=domain) + "?error=cache")
download = DownloadBase()
download.set_task(bulk_import_async.delay(
download.download_id,
config,
domain,
excel_id,
))
try:
del request.session[EXCEL_SESSION_ID]
except KeyError:
pass
return render(
request,
"importer/excel_commit.html", {
'download_id': download.download_id,
'template': 'importer/partials/import_status.html',
'domain': domain,
'report': {
'name': 'Import: Completed'
},
'slug': base.ImportCases.slug
}
)
示例12: form_valid
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def form_valid(self):
download = DownloadBase()
res = prime_restore.delay(
self.domain,
CommCareUser.ids_by_domain(self.domain),
version=V2,
cache_timeout_hours=24,
overwrite_cache=True,
check_cache_only=False
)
download.set_task(res)
return redirect('hq_soil_download', self.domain, download.download_id)
示例13: explode_cases
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def explode_cases(self, request, domain):
user_id = request.POST.get('user_id')
factor = request.POST.get('factor', '2')
try:
factor = int(factor)
except ValueError:
messages.error(request, 'factor must be an int; was: %s' % factor)
else:
download = DownloadBase()
res = explode_case_task.delay(self.domain, user_id, factor)
download.set_task(res)
return redirect('hq_soil_download', self.domain, download.download_id)
示例14: get_export_download
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def get_export_download(domain, export_ids, exports_type, username, filters, filename=None):
from corehq.apps.export.tasks import populate_export_download_task
download = DownloadBase()
download.set_task(populate_export_download_task.delay(
domain,
export_ids,
exports_type,
username,
filters,
download.download_id,
filename=filename
))
return download
示例15: location_export
# 需要导入模块: from soil import DownloadBase [as 别名]
# 或者: from soil.DownloadBase import set_task [as 别名]
def location_export(request, domain):
headers_only = request.GET.get('download_type', 'full') == 'empty'
if not request.can_access_all_locations and not headers_only:
return no_permissions(request)
if not LocationType.objects.filter(domain=domain).exists():
messages.error(request, _("You need to define organization levels before "
"you can do a bulk import or export."))
return HttpResponseRedirect(reverse(LocationsListView.urlname, args=[domain]))
include_consumption = request.GET.get('include_consumption') == 'true'
download = DownloadBase()
res = download_locations_async.delay(domain, download.download_id,
include_consumption, headers_only)
download.set_task(res)
return redirect(DownloadLocationStatusView.urlname, domain, download.download_id)