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)
def before_request(): g.permission = User.auth() if g.permission >= 2: g.this_user = User(session['id'], session['id']) g.sm_av_path = User.get_avatar_mini_path(session['id']) g.av_path = User.get_avatar_path(session['id']) g.connection_ids, g.requested_connection_ids, g.unconfirmed_connection_ids = \ User.get_all_connection_ids(session['id']) g.all_connection_ids = list( set(g.connection_ids + g.requested_connection_ids + g.unconfirmed_connection_ids))