Пример #1
0
def get_form_ready_to_save(metadata, is_db_test=False):
    from corehq.form_processor.parsers.form import process_xform_xml
    from corehq.form_processor.utils import get_simple_form_xml, convert_xform_to_json
    from corehq.form_processor.interfaces.processor import FormProcessorInterface

    assert metadata is not None
    metadata.domain = metadata.domain or uuid.uuid4().hex
    form_id = uuid.uuid4().hex
    form_xml = get_simple_form_xml(form_id=form_id, metadata=metadata)

    if is_db_test:
        wrapped_form = process_xform_xml(metadata.domain, form_xml).submitted_form
    else:
        form_json = convert_xform_to_json(form_xml)
        wrapped_form = FormProcessorInterface(domain=metadata.domain).new_xform(form_json)
        wrapped_form.domain = metadata.domain
    wrapped_form.received_on = metadata.received_on
    return wrapped_form
Пример #2
0
 def _get_xform(self, filename):
     xform = FormProcessorInterface(self.domain).new_xform(convert_xform_to_json(self.get_xml(filename)))
     xform.received_on = self.received_on
     return xform
Пример #3
0
 def _get_xform(self, filename):
     xform = FormProcessorInterface(self.domain).new_xform(
         convert_xform_to_json(self.get_xml(filename)))
     xform.received_on = self.received_on
     return xform