예제 #1
0
파일: views.py 프로젝트: OpenFn/commcare-hq
def location_export(request, domain):
    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)
    download.set_task(res)
    return redirect(DownloadLocationStatusView.urlname, domain, download.download_id)
예제 #2
0
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)
예제 #3
0
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'
    root_location_id = request.GET.get('root_location_id')
    download = DownloadBase()
    res = download_locations_async.delay(domain, download.download_id, include_consumption,
                                         headers_only, root_location_id)
    download.set_task(res)
    return redirect(DownloadLocationStatusView.urlname, domain, download.download_id)
예제 #4
0
파일: views.py 프로젝트: soitun/commcare-hq
def location_export(request, domain):
    headers_only = request.GET.get('download_type', 'full') == 'empty'
    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'
    owner_id = request.couch_user.get_id
    download = DownloadBase()

    form = LocationFilterForm(request.GET, domain=domain, user=request.couch_user)

    if form.is_valid():
        location_filters = form.get_filters()
    else:
        return HttpResponseBadRequest('Location filters invalid')

    root_location_ids = location_filters.pop('location_ids')
    res = download_locations_async.delay(domain, download.download_id, include_consumption,
                                         headers_only, owner_id, root_location_ids, **location_filters)
    download.set_task(res)
    return redirect(DownloadLocationStatusView.urlname, domain, download.download_id)