Exemple #1
0
def dummy_user_xml(user=None):
    username = user.username if user else DUMMY_USERNAME
    password = user.password if user else DUMMY_PASSWORD
    user_id = user.user_id if user else DUMMY_ID
    date_joined = user.date_joined if user else datetime.utcnow()
    project = user.domain if user else DUMMY_PROJECT

    return """
    <Registration xmlns="http://openrosa.org/user/registration">
        <username>{}</username>
        <password>{}</password>
        <uuid>{}</uuid>
        <date>{}</date>
        <user_data>
            <data key="commcare_first_name"/>
            <data key="commcare_last_name"/>
            <data key="commcare_phone_number"/>
            <data key="commcare_project">{}</data>
            <data key="something">arbitrary</data>
        </user_data>
    </Registration>""".format(
        username,
        password,
        user_id,
        date_to_xml_string(date_joined),
        project
    )
Exemple #2
0
def dummy_user_xml(user=None):
    username = user.username if user else DUMMY_USERNAME
    password = user.password if user else DUMMY_PASSWORD
    user_id = user.user_id if user else DUMMY_ID
    date_joined = user.date_joined if user else datetime.utcnow()
    project = user.domain if user else DUMMY_PROJECT

    return """
    <Registration xmlns="http://openrosa.org/user/registration">
        <username>{}</username>
        <password>{}</password>
        <uuid>{}</uuid>
        <date>{}</date>
        <user_data>
            <data key="commcare_first_name"/>
            <data key="commcare_last_name"/>
            <data key="commcare_phone_number"/>
            <data key="commcare_project">{}</data>
            <data key="something">arbitrary</data>
        </user_data>
    </Registration>""".format(
        username,
        password,
        user_id,
        date_to_xml_string(date_joined),
        project
    )
Exemple #3
0
def get_registration_element(restore_user):
    root = safe_element("Registration")
    root.attrib = {"xmlns": USER_REGISTRATION_XMLNS}
    root.append(safe_element("username", restore_user.username))
    root.append(safe_element("password", restore_user.password))
    root.append(safe_element("uuid", restore_user.user_id))
    root.append(safe_element("date", date_to_xml_string(restore_user.date_joined)))
    root.append(get_data_element('user_data', restore_user.user_session_data))
    return root
Exemple #4
0
def get_registration_element(user):
    root = safe_element("Registration")
    root.attrib = {"xmlns": USER_REGISTRATION_XMLNS}
    root.append(safe_element("username", user.username))
    root.append(safe_element("password", user.password))
    root.append(safe_element("uuid", user.user_id))
    root.append(safe_element("date", date_to_xml_string(user.date_joined)))
    root.append(get_data_element('user_data', user.user_session_data))
    return root
Exemple #5
0
def get_registration_element_for_case(case):
    root = safe_element("Registration")
    root.attrib = {"xmlns": USER_REGISTRATION_XMLNS}
    root.append(safe_element("username", case.name))
    root.append(safe_element("password", ""))
    root.append(safe_element("uuid", case.case_id))
    root.append(safe_element("date", date_to_xml_string(case.opened_on)))
    root.append(get_data_element('user_data', {}))
    return root
Exemple #6
0
def get_registration_element_for_case(restore_user, case_id, username):
    if not username:
        username = ''
    root = safe_element("Registration")
    root.attrib = {"xmlns": USER_REGISTRATION_XMLNS}
    root.append(safe_element("username", username))
    root.append(safe_element("password", ""))
    root.append(safe_element("uuid", case_id))
    root.append(safe_element("date", date_to_xml_string(restore_user.date_joined)))
    root.append(get_data_element('user_data', restore_user.user_session_data))
    return root