Example #1
0
def form_list_xml(url, request, **kwargs):
    response = requests.Response()
    factory = RequestFactory()
    req = factory.get(url.path)
    req.user = authenticate(username='******', password='******')
    req.user.profile.require_auth = False
    req.user.profile.save()
    id_string = 'transportation_2011_07_25'
    if url.path.endswith('formList'):
        res = formList(req, username='******')
    elif url.path.endswith('form.xml'):
        res = download_xform(req, username='******', id_string=id_string)
    elif url.path.find('xformsManifest') > -1:
        res = xformsManifest(req, username='******', id_string=id_string)
    elif url.path.find('formid-media') > -1:
        data_id = url.path[url.path.rfind('/') + 1:]
        res = download_media_data(req,
                                  username='******',
                                  id_string=id_string,
                                  data_id=data_id)
        response._content = get_streaming_content(res)
    else:
        res = formList(req, username='******')
    response.status_code = 200
    if not response._content:
        response._content = res.content
    return response
Example #2
0
def form_list_xml(url, request, **kwargs):
    response = requests.Response()
    factory = RequestFactory()
    req = factory.get(url.path)
    req.user = authenticate(username='******', password='******')
    req.user.profile.require_auth = False
    req.user.profile.save()
    id_string = 'transportation_2011_07_25'
    # Retrieve XForm pk for user bob.
    # SQLite resets PK to 1 every time the table is truncated (i.e. after
    # each test is over) whereas PostgreSQL keeps the last sequence value
    # which makes `xform_id` differ all the time.
    xform_id = (XForm.objects.values_list(
        'id', flat=True).filter(user__username='******').last())
    if url.path.endswith('formList'):
        res = formList(req, username='******')
    elif url.path.endswith('form.xml'):
        res = download_xform(req, username='******', id_string=id_string)
    elif url.path.find('xformsManifest') > -1:
        res = xformsManifest(req, username='******', pk=xform_id)
    elif url.path.find('formid-media') > -1:
        data_id = url.path[url.path.rfind('/') + 1:]
        res = download_media_data(req,
                                  username='******',
                                  id_string=id_string,
                                  data_id=data_id)
        response._content = get_streaming_content(res)
    else:
        res = formList(req, username='******')
    response.status_code = 200
    if not response._content:
        response._content = res.content
    return response
Example #3
0
def form_list_xml(url, request, **kwargs):
    response = requests.Response()
    factory = RequestFactory()
    req = factory.get(url.path)
    req.user = authenticate(username='******', password='******')
    req.user.profile.require_auth = False
    req.user.profile.save()
    id_string = 'transportation_2011_07_25'
    if url.path.endswith('formList'):
        res = formList(req, username='******')
    elif url.path.endswith('form.xml'):
        res = download_xform(req, username='******', id_string=id_string)
    elif url.path.find('xformsManifest') > -1:
        res = xformsManifest(req, username='******', id_string=id_string)
    elif url.path.find('formid-media') > -1:
        data_id = url.path[url.path.rfind('/') + 1:]
        res = download_media_data(
            req, username='******', id_string=id_string, data_id=data_id)
        response._content = get_streaming_content(res)
    else:
        res = formList(req, username='******')
    response.status_code = 200
    if not response._content:
        response._content = res.content
    return response