Beispiel #1
0
def settings_photo_view():
    if g.permission < 1:
        flash(NOT_AUTH_MSG, 'text-warning')
        return redirect('/')
    if request.method == 'POST':
        user_photos = request.get_json()
        avatar_photo_id = user_photos['avatar_photo_id']
        photos_to_del = user_photos['photos_to_del']
        del user_photos['avatar_photo_id']
        del user_photos['photos_to_del']
        for photo_to_del in photos_to_del:
            User.delete_photo(int(photo_to_del), session['id'])
            User.update_sexuality(session['id'], -5)
        for key, val in user_photos.items():
            User.update_access_status(session['login'], 3)
            image_string = val.split(',')[1]
            User.save_photos(key, image_string, session['id'])
            User.update_sexuality(session['id'], 5)
        User.set_avatar(avatar_photo_id, session['id'], session['login'])
        flash(UPDATED, 'text-success')
        data = {'response': 'OK'}
        return jsonify(data)
    avatar_path = User.get_avatar_path(session['id'])
    photos = User.get_photos_path(session['id'])
    grep_img_funct = User.grep_image_number
    return render_template('settings_photos.html',
                           avatar_path=avatar_path,
                           photos=photos,
                           grep_img_funct=grep_img_funct)
Beispiel #2
0
def cabinet_view():
    if g.permission < 1:
        flash(NOT_AUTH_MSG, 'text-warning')
        return redirect('/')
    connections_confirmed = User.get_all_connections(g.connection_ids,
                                                     session['id'])
    connections_requested = User.get_all_connections(
        g.requested_connection_ids, session['id'])
    connections_unconfirmed = User.get_all_connections(
        g.unconfirmed_connection_ids, session['id'])
    connections_unconfirmed = list(
        filter(lambda x: not x.is_blocked, connections_unconfirmed))
    user_photos = User.get_photos_path(session['id'])
    user_data = User.get_profile_settings_from_db(session['id'])
    visit_history = VisitHistory.get_visit_history(session['id'])
    return render_template('cabinet.html',
                           user_photos=user_photos,
                           user_data=user_data,
                           connections_confirmed=connections_confirmed,
                           connections_requested=connections_requested,
                           connections_unconfirmed=connections_unconfirmed,
                           visit_history=visit_history)