Example #1
0
 def get_all_ids(self, database=None):
     database = database or self.get_db()
     return set(
         [result['id'] for result in database.view(
                     "couchexport/schema_index",
                     reduce=False,
                     **get_schema_index_view_keys(self.index)).all()])
Example #2
0
 def get_all_ids(self, database=None):
     database = database or self.get_db()
     return set(
         [result['id'] for result in database.view(
                     "couchexport/schema_index",
                     reduce=False,
                     **get_schema_index_view_keys(self.index)).all()])
Example #3
0
 def all_doc_ids(self):
     """
     Gets view results for all documents matching this schema
     """
     return set([result['id'] for result in \
                 self.database.view(
                     "couchexport/schema_index",
                     reduce=False,
                     **get_schema_index_view_keys(self.schema_index)
                 ).all()])
Example #4
0
 def all_doc_ids(self):
     """
     Gets view results for all documents matching this schema
     """
     return set([result['id'] for result in \
                 self.database.view(
                     "couchexport/schema_index",
                     reduce=False,
                     **get_schema_index_view_keys(self.schema_index)
                 ).all()])
Example #5
0
def export_raw_data(export_tag, filename=None):
    # really this shouldn't be here, but keeping it for now
    from couchforms.models import XFormInstance
    xform_instances = XFormInstance.view('couchexport/schema_index',
                                         include_docs=True,
                                         reduce=False,
                                         **get_schema_index_view_keys(export_tag))
    f = io.BytesIO()
    zipfile = ZipFile(f, 'w')
    for xform_instance in xform_instances:
        form_xml = xform_instance.fetch_attachment('form.xml', return_bytes=True)
        zipfile.writestr("%s.xml" % xform_instance.get_id, form_xml)
    zipfile.close()
    f.flush()
    response = HttpResponse(f.getvalue())
    f.close()
    response['Content-Type'] = "application/zip"
    response['Content-Disposition'] = 'attachment; filename="%s.zip"' % filename
    return response
Example #6
0
def export_raw_data(export_tag, filename=None):
    # really this shouldn't be here, but keeping it for now
    from couchforms.models import XFormInstance
    xform_instances = XFormInstance.view(
        'couchexport/schema_index',
        include_docs=True,
        reduce=False,
        **get_schema_index_view_keys(export_tag))
    f = StringIO()
    zipfile = ZipFile(f, 'w')
    for xform_instance in xform_instances:
        form_xml = xform_instance.fetch_attachment('form.xml').encode('utf-8')
        zipfile.writestr("%s.xml" % xform_instance.get_id, form_xml)
    zipfile.close()
    f.flush()
    response = HttpResponse(f.getvalue())
    f.close()
    response['Content-Type'] = "application/zip"
    response['Content-Disposition'] = "attachment; filename=%s.zip" % filename
    return response