当前位置: 首页>>代码示例>>Python>>正文


Python DownloadBase.set_task方法代码示例

本文整理汇总了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,
    })
开发者ID:dimagi,项目名称:commcare-hq,代码行数:32,代码来源:download.py

示例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()
开发者ID:bradmerlin,项目名称:commcare-hq,代码行数:27,代码来源:views.py

示例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)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:37,代码来源:users.py

示例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,
     })
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:28,代码来源:views.py

示例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()
开发者ID:nnestle,项目名称:commcare-hq,代码行数:12,代码来源:models.py

示例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
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:12,代码来源:export.py

示例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()
开发者ID:kennknowles,项目名称:commcare-hq,代码行数:13,代码来源:views.py

示例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()
开发者ID:dslowikowski,项目名称:commcare-hq,代码行数:13,代码来源:views.py

示例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
开发者ID:hashimoto-hb,项目名称:commcare-hq,代码行数:14,代码来源:views.py

示例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)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:14,代码来源:users.py

示例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
        }
    )
开发者ID:johan--,项目名称:commcare-hq,代码行数:55,代码来源:views.py

示例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)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:15,代码来源:views.py

示例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)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:15,代码来源:views.py

示例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
开发者ID:dimagi,项目名称:commcare-hq,代码行数:16,代码来源:export.py

示例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)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:16,代码来源:views.py


注:本文中的soil.DownloadBase.set_task方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。