Пример #1
0
def publish_xml_form(xml_file, user, project, id_string=None, created_by=None):
    xml = xml_file.read()
    survey = create_survey_element_from_xml(xml)
    form_json = survey.to_json()
    if id_string:
        dd = DataDictionary.objects.get(user=user,
                                        id_string=id_string,
                                        project=project)
        dd.xml = xml
        dd.json = form_json
        dd._mark_start_time_boolean()
        set_uuid(dd)
        dd._set_uuid_in_xml()
        dd.save()

        return dd
    else:
        created_by = created_by or user
        dd = DataDictionary(created_by=created_by,
                            user=user,
                            xml=xml,
                            json=form_json,
                            project=project)
        dd._mark_start_time_boolean()
        set_uuid(dd)
        dd._set_uuid_in_xml(file_name=xml_file.name)
        dd.save()

        return dd
Пример #2
0
def publish_xml_form(xml_file, user, project, id_string=None, created_by=None):
    xml = xml_file.read()
    survey = create_survey_element_from_xml(xml)
    form_json = survey.to_json()
    if id_string:
        dd = DataDictionary.objects.get(
            user=user, id_string=id_string, project=project)
        dd.xml = xml
        dd.json = form_json
        dd._mark_start_time_boolean()
        set_uuid(dd)
        dd._set_uuid_in_xml()
        dd.save()

        return dd
    else:
        created_by = created_by or user
        dd = DataDictionary(created_by=created_by, user=user, xml=xml,
                            json=form_json, project=project)
        dd._mark_start_time_boolean()
        set_uuid(dd)
        dd._set_uuid_in_xml(file_name=xml_file.name)
        dd.save()

        return dd
Пример #3
0
def publish_xml_form(xml_file, user, project, id_string=None, created_by=None):
    xml = xml_file.read()
    if isinstance(xml, bytes):
        xml = xml.decode('utf-8')
    survey = create_survey_element_from_xml(xml)
    form_json = survey.to_json()
    if id_string:
        dd = DataDictionary.objects.get(user=user,
                                        id_string=id_string,
                                        project=project)
        dd.xml = xml
        dd.json = form_json
        dd._mark_start_time_boolean()
        set_uuid(dd)
        dd._set_uuid_in_xml()
        dd._set_hash()
        dd.save()
    else:
        created_by = created_by or user
        dd = DataDictionary(created_by=created_by,
                            user=user,
                            xml=xml,
                            json=form_json,
                            project=project)
        dd._mark_start_time_boolean()
        set_uuid(dd)
        dd._set_uuid_in_xml(file_name=xml_file.name)
        dd._set_hash()
        dd.save()

    # Create an XFormVersion object for the published XLSForm
    create_xform_version(dd, user)
    return dd