def _create_user_for_contact(values):
    user = User()
    name = values.get('name')
    if is_empty(name):
        user, created = User.objects.get_or_create(username='******')
    else:
        name = name.strip()
        clean_name = name.replace(" ", "_").lower()
        unique_name = _get_unique_username(clean_name,0)
        user.username = unique_name
        user.first_name = name.title()
        user.email = '*****@*****.**'
        user.set_password('password')
    return user
def _parse_name(name):
    if is_empty(name):
        return "Anonymous User"
    return name.strip().title()
def _set_reporting_location(district, contact):
    if is_empty(district):
        contact.reporting_location = Location.tree.root_nodes()[0]
    contact.reporting_location = find_closest_match(district,
            Location.objects.filter(type__slug='district'))
예제 #4
0
 def lookup_by_connection(cls, connection):
     contact = Contact.objects.filter(connection=connection)
     return None if is_empty(contact) else ConnectionProfile(contact[0].user)