Beispiel #1
0
def create_consumer(member):
    password = NeoProfile.generate_password()
    login_alias = normalize_username(member.username)
    wrapper = wrap_member(member, login_alias=login_alias, password=password)
    consumer_id, uri = api.create_consumer(wrapper.consumer)
    api.complete_registration(consumer_id)  # activates the account
    # the NeoProfile needs to be saved elsewhere when member has been saved
    return NeoProfile(user=member, consumer_id=consumer_id,
                      password=password, login_alias=login_alias)
Beispiel #2
0
def create_consumer(member):
    wrapper = ConsumerWrapper()
    for a in NEO_ATTR:
        getattr(wrapper, "set_%s" % a)(getattr(member, a))
    wrapper.set_password(member.raw_password)
    del member.raw_password

    # assign address
    has_address = False
    for k in ADDRESS_FIELDS:
        if getattr(member, k, None):
            has_address = True
            break
    if has_address:
        wrapper.set_address(member.address, member.city,
            member.province, member.zipcode, member.country)

    consumer_id, uri = api.create_consumer(wrapper.consumer)
    api.complete_registration(consumer_id)  # activates the account
    return consumer_id