@view_config(renderer="user_info.mak", route_name='user_info')
def user_info(request):
    import hashlib
    import os
    from raggregate.queries import user_preference as up

    r = request
    ses = request.session
    p = ses['safe_post']

    edit_mode = False
    user_id = None

    if 'user_id' in r.params:
        user_id = r.params['user_id']

    if 'logged_in' in ses and 'user_id' not in r.params:
        user_id = ses['users.id']

    if 'logged_in' in ses and (user_id == str(ses['users.id']) or users.get_user_by_id(ses['users.id']).is_user_admin()):
        edit_mode = True

    u = users.get_user_by_id(user_id)
    params = up.get_user_prefs(user_id)

    if p and edit_mode:
        dbsession = DBSession()
        u.about_me = p['about_me']
        if p['email'] == "":
            u.email = None
        else:
            u.email = p['email']
        if r.POST['picture'] != '':
            orig_filename = r.POST['picture'].filename
            up_dir = r.registry.settings['user.picture_upload_directory']

            u.picture = users.add_user_picture(orig_filename, str(u.id)[:7], up_dir, r.POST['picture'].file)

        dbsession.add(u)

    response = {'edit_mode': edit_mode, 'u': u}
    response.update(params)
    return response
dataset/ETHPy150Open sjuxax/raggregate/raggregate/views/user.py/user_info/original