Ejemplo n.º 1
0
def upload():

    file = request.files['file']
    size = request.content_length

    if not file:
        print "No File to Upload."
        return jsonify(status="No File to Upload.")
    elif size > ALLOWED_SIZE:
        print "File size more then 10Mb."
        return jsonify(status="File size more then 10Mb.")
    elif not allowed_file(file.filename):
        print "This file extesion not allowed."
        return jsonify(status="This file extesion not allowed.")
    elif file and allowed_file(file.filename):
        try:
            upload_file(file)
        except:
            print "Failed to upload. Some error occured."
            return jsonify(status="Failed to upload. Some error occured.")
    else:
        print "Some error occured."
        return jsonify(status="Some error occured.")

    return jsonify(filename=file.filename, status="Uploaded")
Ejemplo n.º 2
0
def item_new():
    if 'username' not in login_session:
        return redirect('/login')

    try:
        if request.method == 'POST' and request.form['title'] != "":
            image = request.files['image']
            image_filename = None
            if allowed_file(image.filename):
                image.save(os.path.join(app.config['UPLOAD_FOLDER'], image.filename))
                image_filename = image.filename

            category = session.query(Category).filter_by(name=request.form['category']).one()
            if image_filename is None:
                item = Item(title=request.form['title'], description=request.form['description'], category=category)
            else:
                item = Item(title=request.form['title'], description=request.form['description'], category=category,
                            picture=image_filename)
            session.add(item)
            session.commit()
            return redirect(url_for('index'))
        else:
            categories = session.query(Category).all()
            return render_template('item_add.html', categories=categories, login_state=user_logged_in())
    except NoResultFound:
        return redirect(url_for('index'))
Ejemplo n.º 3
0
def item_edit(item_id):
    if 'username' not in login_session:
        return redirect('/login')

    try:
        item = session.query(Item).filter_by(id=item_id).one()
        if request.method == 'POST':
            item.title = request.form['title']
            item.description = request.form['description']
            item_category = session.query(Category).filter_by(name=request.form['category']).one()
            item.category = item_category

            image = request.files['image']
            if allowed_file(image.filename):
                os.remove(os.path.join(app.config['UPLOAD_FOLDER'], item.picture))
                image.save(os.path.join(app.config['UPLOAD_FOLDER'], image.filename))
                item.picture = image.filename

            session.commit()
            return redirect(url_for('index'))
        else:
            categories = session.query(Category).all()
            return render_template('item_edit.html', item=item, categories=categories, login_state=user_logged_in())
    except NoResultFound:
        return redirect(url_for('index'))
Ejemplo n.º 4
0
def editTeam(team_id):
    if 'username' not in login_session:
        return redirect('/login')
    team = session.query(Team).filter_by(id=team_id).one()
    if team.created_by != login_session['user_id']:
        return "<script>function myFunction() {alert('You are not authorized to edit this team. Please create your own team in order to edit.');}</script><body onload='myFunction()''>"
    if request.method=="POST":
        team.name=request.form['name']
        team.locallity=request.form['locallity']
        team.game_id=request.form['game_id']
        team.is_active='1' if request.form['status'] == 'Active' else '0'
        team.name=request.form['name']
        if team.logo != request.files['logo']:
            file = request.files['logo']
            if file and helper.allowed_file(file.filename):
                extension = file.filename.rsplit('.' ,1)
                filename = secure_filename(file.filename)
                filename = helper.hash_filename(filename)+"."+extension[1]
                team.logo = filename
                # saves file in file system
                file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        session.add(team)
        session.commit()
        flash('Team Successfully Edited %s' % team.name)
        return redirect(url_for('showTeams'))
    else:
        games= session.query(Game)
        return render_template('teams/editteam.html', team=team, games=games)
Ejemplo n.º 5
0
def upload_image():
    f = request.files.get('upload')
    if not allowed_file(f.filename):
        return upload_fail('Image only!')
    f.save(os.path.join(current_app.config['CLEARLOG_UPLOAD_PATH'], f.filename))
    url = url_for('.get_image', filename=f.filename)
    return upload_success(url, f.filename)
Ejemplo n.º 6
0
def editTeam(team_id):
    if 'username' not in login_session:
        return redirect('/login')
    team = session.query(Team).filter_by(id=team_id).one()
    if team.created_by != login_session['user_id']:
        return "<script>function myFunction() {alert('You are not authorized to edit this team. Please create your own team in order to edit.');}</script><body onload='myFunction()''>"
    if request.method == "POST":
        team.name = request.form['name']
        team.locallity = request.form['locallity']
        team.game_id = request.form['game_id']
        team.is_active = '1' if request.form['status'] == 'Active' else '0'
        team.name = request.form['name']
        if team.logo != request.files['logo']:
            file = request.files['logo']
            if file and helper.allowed_file(file.filename):
                extension = file.filename.rsplit('.', 1)
                filename = secure_filename(file.filename)
                filename = helper.hash_filename(filename) + "." + extension[1]
                team.logo = filename
                # saves file in file system
                file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        session.add(team)
        session.commit()
        flash('Team Successfully Edited %s' % team.name)
        return redirect(url_for('showTeams'))
    else:
        games = session.query(Game)
        return render_template('teams/editteam.html', team=team, games=games)
Ejemplo n.º 7
0
def newPlayer(team_id):
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == "POST":
        file = request.files['picture']
        if file and helper.allowed_file(file.filename):
            extension = file.filename.rsplit('.' ,1)
            filename = secure_filename(file.filename)
            filename = helper.hash_filename(filename)+"."+extension[1]
            # saves file in file system
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        else:
            filename = 'no_picture.jpg'
        newPlayer = Player(
            name=request.form['name'],
            email=request.form['email'],
            phone=request.form['phone'],
            skill_level=request.form['skill_level'],
            picture=filename,
            summary=request.form['summary'],
            team_id=team_id,
            share_contact=request.form['share_contact'],
            created_on=datetime.datetime.strptime(strftime("%Y-%m-%d %H:%M:%S", localtime()), "%Y-%m-%d %H:%M:%S"),
            created_by=login_session['user_id'],
            is_active='1' if request.form['status'] == 'Active' else '0',
            is_delete='0',
            )
        session.add(newPlayer)
        session.commit()
        flash('New Player %s Successfully Created' % newPlayer.name)
        return redirect(url_for('showPlayers', team_id=team_id))
    else:
        skill_levels = ['Beginner', 'Intermediate', 'Advanced']
        return render_template('players/newplayer.html', skill_levels=skill_levels)
Ejemplo n.º 8
0
def item_new():
    if 'username' not in login_session:
        return redirect('/login')

    try:
        if request.method == 'POST' and request.form['title'] != "":
            image = request.files['image']
            image_filename = None
            if allowed_file(image.filename):
                image.save(
                    os.path.join(app.config['UPLOAD_FOLDER'], image.filename))
                image_filename = image.filename

            category = session.query(Category).filter_by(
                name=request.form['category']).one()
            if image_filename is None:
                item = Item(title=request.form['title'],
                            description=request.form['description'],
                            category=category)
            else:
                item = Item(title=request.form['title'],
                            description=request.form['description'],
                            category=category,
                            picture=image_filename)
            session.add(item)
            session.commit()
            return redirect(url_for('index'))
        else:
            categories = session.query(Category).all()
            return render_template('item_add.html',
                                   categories=categories,
                                   login_state=user_logged_in())
    except NoResultFound:
        return redirect(url_for('index'))
Ejemplo n.º 9
0
def newTeam():
    if 'username' not in login_session:
        return redirect('/login')
    games = session.query(Game)
    if request.method == "POST":
        file = request.files['logo']
        if file and helper.allowed_file(file.filename):
            extension = file.filename.rsplit('.' ,1)
            filename = secure_filename(file.filename)
            filename = helper.hash_filename(filename)+"."+extension[1]
            # saves file in file system
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        else:
            filename = 'no_logo.jpg'
        strdate = request.form['start_year'].rsplit('/', 1)
        dateObj = datetime.datetime.strptime(strdate[1], "%Y").date()
        newTeam = Team(
            name=request.form['name'],
            locallity=request.form['locallity'],
            logo=filename,
            start_year=dateObj,
            game_id=request.form['game_id'],
            created_on=datetime.datetime.strptime(strftime("%Y-%m-%d %H:%M:%S", localtime()), "%Y-%m-%d %H:%M:%S"),
            created_by=login_session['user_id'],
            is_active='1' if request.form['status'] == 'Active' else '0',
            is_delete='0',
            )
        session.add(newTeam)
        session.commit()
        flash('New Team %s Successfully Created' % newTeam.name)
        return redirect(url_for('showTeams'))
    else:
        return render_template('teams/newteam.html', games=games)
Ejemplo n.º 10
0
def item_edit(item_id):
    if 'username' not in login_session:
        return redirect('/login')

    try:
        item = session.query(Item).filter_by(id=item_id).one()
        if request.method == 'POST':
            item.title = request.form['title']
            item.description = request.form['description']
            item_category = session.query(Category).filter_by(
                name=request.form['category']).one()
            item.category = item_category

            image = request.files['image']
            if allowed_file(image.filename):
                os.remove(
                    os.path.join(app.config['UPLOAD_FOLDER'], item.picture))
                image.save(
                    os.path.join(app.config['UPLOAD_FOLDER'], image.filename))
                item.picture = image.filename

            session.commit()
            return redirect(url_for('index'))
        else:
            categories = session.query(Category).all()
            return render_template('item_edit.html',
                                   item=item,
                                   categories=categories,
                                   login_state=user_logged_in())
    except NoResultFound:
        return redirect(url_for('index'))
Ejemplo n.º 11
0
def getImage(path):
    l_path = path.split('/')
    if len(l_path) != 2: abort(404)
    if not isSegment(l_path[0]): abort(404)
    segment = l_path[0]
    image_name = l_path[1]
    if not allowed_file(image_name): abort(400)
    directory = os.path.join(app.config['UPLOAD_FOLDER'], segment)
    image_path = os.path.join(directory, image_name)
    if os.path.exists(image_path):
        return send_from_directory(directory, image_name)
    if not isResizedImage(image_name): abort(404)
    params = getRequestedParameters(image_name)
    if not params: abort(500)
    stock_image_path = os.path.join(directory, params['name'])
    if not os.path.exists(stock_image_path): abort(404)
    img = Image.open(stock_image_path)
    size = (round(params['height'] * img.size[0] /
                  img.size[1]) if params['width'] is None else params['width'],
            round(params['width'] * img.size[1] / img.size[0])
            if params['height'] is None else params['height'])
    if size[0] > app.config['MAX_IMAGE_SIZE'][0] or size[1] > app.config[
            'MAX_IMAGE_SIZE'][1]:
        abort(400)
    if size == img.size: return send_from_directory(directory, params['name'])
    img.resize(size, Image.BICUBIC).save(image_path)
    if os.path.exists(image_path):
        return send_from_directory(directory, image_name)
    abort(500)
Ejemplo n.º 12
0
def newTeam():
    if 'username' not in login_session:
        return redirect('/login')
    games = session.query(Game)
    if request.method == "POST":
        file = request.files['logo']
        if file and helper.allowed_file(file.filename):
            extension = file.filename.rsplit('.', 1)
            filename = secure_filename(file.filename)
            filename = helper.hash_filename(filename) + "." + extension[1]
            # saves file in file system
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        else:
            filename = 'no_logo.jpg'
        strdate = request.form['start_year'].rsplit('/', 1)
        dateObj = datetime.datetime.strptime(strdate[1], "%Y").date()
        newTeam = Team(
            name=request.form['name'],
            locallity=request.form['locallity'],
            logo=filename,
            start_year=dateObj,
            game_id=request.form['game_id'],
            created_on=datetime.datetime.strptime(
                strftime("%Y-%m-%d %H:%M:%S", localtime()),
                "%Y-%m-%d %H:%M:%S"),
            created_by=login_session['user_id'],
            is_active='1' if request.form['status'] == 'Active' else '0',
            is_delete='0',
        )
        session.add(newTeam)
        session.commit()
        flash('New Team %s Successfully Created' % newTeam.name)
        return redirect(url_for('showTeams'))
    else:
        return render_template('teams/newteam.html', games=games)
Ejemplo n.º 13
0
def editPlayer(team_id, player_id):
    if 'username' not in login_session:
        return redirect('/login')
    player = session.query(Player).filter_by(team_id=team_id, is_delete='0', id=player_id).one()
    if player.created_by != login_session['user_id']:
        return "<script>function myFunction() {alert('You are not authorized to edit this player. Please create your own player in order to edit.');}</script><body onload='myFunction()''>"
    team = session.query(Team).filter_by(id=team_id).one()
    skill_levels = ['Beginner', 'Intermediate', 'Advanced']
    if request.method == "POST":
        player.name=request.form['name']
        player.email=request.form['email']
        player.phone=request.form['phone']
        player.skill_level=request.form['skill_level']
        player.summary=request.form['summary']
        player.is_active='1' if request.form['status'] == 'Active' else '0'
        player.share_contact=request.form['share_contact']

        if player.picture != request.files['picture']:
            file = request.files['picture']
            if file and helper.allowed_file(file.filename):
                extension = file.filename.rsplit('.' ,1)
                filename = secure_filename(file.filename)
                filename = helper.hash_filename(filename)+"."+extension[1]
                player.picture = filename
                # saves file in file system
                file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        session.add(player)
        session.commit()
        flash('Player %s Edited Successfully' % player.name)
        return redirect(url_for('showPlayers', team_id=team_id))
    return render_template('players/editplayer.html', skill_levels=skill_levels, player=player,team=team)
Ejemplo n.º 14
0
def edit_type(dbtype, item_id):
    """Edit the category (within 3 pre-defined type) in the database"""
    # check login status
    if 'email' not in login_session:
        flash('Sorry, the page you tried to access is for members only. '
              'Please sign in first.')
        abort(401)

    # query the item user wants to edit
    edit_item = (session.query(eval(
        dbtype.capitalize())).filter_by(id=item_id).one())
    # make sure user is authorized to edit this item
    if login_session['user_id'] != edit_item.user_id:
        flash('You are not authorized to modify items you did not create. '
              'Please create your own item in order to modify it.')
        return redirect(url_for(dbtype))

    # get property names from table
    table = Table(dbtype, meta, autoload=True, autoload_with=engine)

    if request.method == 'POST':
        for column in table.columns:
            if column.name in ('id', 'user_id'):
                pass  # don't modify item id# and user_id#
            else:
                # set attribute of query object with request form data
                setattr(edit_item, column.name, request.form[column.name])
        session.add(edit_item)
        session.commit()
        flash('%s Edited' % dbtype.capitalize())

        # upload image
        image = request.files['picture']
        if image and allowed_file(image.filename):
            with store_context(fs_store):
                edit_item.picture.from_file(image)
        # prevent user uploading unsupported file type
        elif image and not allowed_file(image.filename):
            flash('Unsupported file detected. No image has been uploaded.')
        return redirect(url_for(dbtype))
    else:
        return render_template('edit-type.html',
                               dbtype=dbtype,
                               columns=table.columns,
                               item_id=item_id,
                               edit_item=edit_item)
Ejemplo n.º 15
0
def edit_type(dbtype, item_id):
    """Edit the category (within 3 pre-defined type) in the database"""
    # check login status
    if 'email' not in login_session:
        flash('Sorry, the page you tried to access is for members only. '
              'Please sign in first.')
        abort(401)

    # query the item user wants to edit
    edit_item = (session.query(eval(dbtype.capitalize()))
                 .filter_by(id=item_id).one())
    # make sure user is authorized to edit this item
    if login_session['user_id'] != edit_item.user_id:
        flash('You are not authorized to modify items you did not create. '
              'Please create your own item in order to modify it.')
        return redirect(url_for(dbtype))

    # get property names from table
    table = Table(dbtype, meta, autoload=True, autoload_with=engine)

    if request.method == 'POST':
        for column in table.columns:
            if column.name in ('id', 'user_id'):
                pass  # don't modify item id# and user_id#
            else:
                # set attribute of query object with request form data
                setattr(edit_item, column.name, request.form[column.name])
        session.add(edit_item)
        session.commit()
        flash('%s Edited' % dbtype.capitalize())

        # upload image
        image = request.files['picture']
        if image and allowed_file(image.filename):
            with store_context(fs_store):
                edit_item.picture.from_file(image)
        # prevent user uploading unsupported file type
        elif image and not allowed_file(image.filename):
            flash('Unsupported file detected. No image has been uploaded.')
        return redirect(url_for(dbtype))
    else:
        return render_template('edit-type.html', dbtype=dbtype,
                               columns=table.columns, item_id=item_id,
                               edit_item=edit_item)
Ejemplo n.º 16
0
def upload_file():
    token = request.form['token']

    file = request.files['file']
    if file and helper.allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        database_helper.post_message_file(filename, token)
        return 'uploaded'
    return 'error'
Ejemplo n.º 17
0
def upload_file():
    token = request.form['token']

    file = request.files['file']
    if file and helper.allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        database_helper.post_message_file(filename, token)
        return 'uploaded'
    return 'error'
Ejemplo n.º 18
0
def load_data(context):

    if request.method == 'GET':
        return render_template('load_data.html')

    # Upload file
    elif request.method == 'POST':

        if 'Back' in request.form:
            return redirect(url_for('index'))

        # check if the post request has the file part
        if 'file' not in request.files:
            flash('No file part', 'error')
            return redirect(request.url)

        file = request.files['file']

        # if user does not select file, browser also
        # submit a empty part without filename
        if file.filename == '':
            flash('No selected file', 'error')
            return redirect(request.url)

        if not allowed_file(file.filename, app.config['ALLOWED_EXTENSIONS']):
            flash(
                'Wrong input format. Can be {}'.format(", ".join(
                    app.config['ALLOWED_EXTENSIONS'])) + ".", 'error')
            return redirect(request.url)

        if file and allowed_file(file.filename,
                                 app.config['ALLOWED_EXTENSIONS']):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

            session['filename'] = filename
            session.modified = True

            if context == 'find_model':
                return redirect(url_for('features_selection', context=context))

            elif context == 'run_model':
                return redirect(url_for('previous_algo', context=context))
Ejemplo n.º 19
0
def upload():
    if request.form['secret_key'] != config.SECRET_KEY: abort(403)
    if 'image' not in request.files: abort(400)
    image = request.files['image']
    if image.filename == '': return abort(400)
    if not image or not allowed_file(image.filename): return abort(400)
    filename = prepare_name(image.filename)
    path_segment = getPathSegment(filename)
    full_path = os.path.join(app.config['UPLOAD_FOLDER'], path_segment)
    if not os.path.exists(full_path): os.makedirs(full_path)
    image_path = os.path.join(full_path, filename)
    image.save(image_path)
    return image_path[1:]
Ejemplo n.º 20
0
def create_type(dbtype):
    """
    Create new category (within 3 pre-defined type) in the database
    """
    # check login status
    if 'email' not in login_session:
        flash('Sorry, the page you tried to access is for members only. '
              'Please sign in first.')
        return redirect(url_for(dbtype))

    # get property names from table
    table = Table(dbtype, meta, autoload=True, autoload_with=engine)
    user_id = get_user_id(login_session['email'])

    if request.method == 'POST':
        # instantiate new object
        new = eval(dbtype.capitalize())()
        for field in request.form:
            # set attribute of new object with request form data
            if hasattr(new, field):
                setattr(new, field, request.form[field])
        setattr(new, 'user_id', user_id)
        session.add(new)
        session.commit()
        flash('%s Created' % dbtype.capitalize())

        # upload image
        image = request.files['picture']
        if image and allowed_file(image.filename):
            with store_context(fs_store):
                new.picture.from_file(image)
        # prevent user uploading unsupported file type
        elif image and not allowed_file(image.filename):
            flash('Unsupported file detected. No image has been uploaded.')
        return redirect(url_for(dbtype))
    else:
        return render_template('create-type.html',
                               columns=table.columns,
                               dbtype=dbtype)
Ejemplo n.º 21
0
def create_type(dbtype):
    """
    Create new category (within 3 pre-defined type) in the database
    """
    # check login status
    if 'email' not in login_session:
        flash('Sorry, the page you tried to access is for members only. '
              'Please sign in first.')
        return redirect(url_for(dbtype))

    # get property names from table
    table = Table(dbtype, meta, autoload=True, autoload_with=engine)
    user_id = get_user_id(login_session['email'])

    if request.method == 'POST':
        # instantiate new object
        new = eval(dbtype.capitalize())()
        for field in request.form:
            # set attribute of new object with request form data
            if hasattr(new, field):
                setattr(new, field, request.form[field])
        setattr(new, 'user_id', user_id)
        session.add(new)
        session.commit()
        flash('%s Created' % dbtype.capitalize())

        # upload image
        image = request.files['picture']
        if image and allowed_file(image.filename):
            with store_context(fs_store):
                new.picture.from_file(image)
        # prevent user uploading unsupported file type
        elif image and not allowed_file(image.filename):
            flash('Unsupported file detected. No image has been uploaded.')
        return redirect(url_for(dbtype))
    else:
        return render_template('create-type.html',
                               columns=table.columns, dbtype=dbtype)
Ejemplo n.º 22
0
def upload_file():
    # check if the post request has the file part
    if 'file' not in request.files:
        flash('No file part')
        return redirect(request.url)
    file = request.files['file']

    # if user does not select file or submits an empty part without filename
    if file.filename == '':
        flash('No selected file')
        return redirect(request.url)
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save("images/" + filename)
        return redirect(url_for('detect'))
Ejemplo n.º 23
0
def newPlayer(team_id):
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == "POST":
        file = request.files['picture']
        if file and helper.allowed_file(file.filename):
            extension = file.filename.rsplit('.', 1)
            filename = secure_filename(file.filename)
            filename = helper.hash_filename(filename) + "." + extension[1]
            # saves file in file system
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        else:
            filename = 'no_picture.jpg'
        newPlayer = Player(
            name=request.form['name'],
            email=request.form['email'],
            phone=request.form['phone'],
            skill_level=request.form['skill_level'],
            picture=filename,
            summary=request.form['summary'],
            team_id=team_id,
            share_contact=request.form['share_contact'],
            created_on=datetime.datetime.strptime(
                strftime("%Y-%m-%d %H:%M:%S", localtime()),
                "%Y-%m-%d %H:%M:%S"),
            created_by=login_session['user_id'],
            is_active='1' if request.form['status'] == 'Active' else '0',
            is_delete='0',
        )
        session.add(newPlayer)
        session.commit()
        flash('New Player %s Successfully Created' % newPlayer.name)
        return redirect(url_for('showPlayers', team_id=team_id))
    else:
        skill_levels = ['Beginner', 'Intermediate', 'Advanced']
        return render_template('players/newplayer.html',
                               skill_levels=skill_levels)
Ejemplo n.º 24
0
def editPlayer(team_id, player_id):
    if 'username' not in login_session:
        return redirect('/login')
    player = session.query(Player).filter_by(team_id=team_id,
                                             is_delete='0',
                                             id=player_id).one()
    if player.created_by != login_session['user_id']:
        return "<script>function myFunction() {alert('You are not authorized to edit this player. Please create your own player in order to edit.');}</script><body onload='myFunction()''>"
    team = session.query(Team).filter_by(id=team_id).one()
    skill_levels = ['Beginner', 'Intermediate', 'Advanced']
    if request.method == "POST":
        player.name = request.form['name']
        player.email = request.form['email']
        player.phone = request.form['phone']
        player.skill_level = request.form['skill_level']
        player.summary = request.form['summary']
        player.is_active = '1' if request.form['status'] == 'Active' else '0'
        player.share_contact = request.form['share_contact']

        if player.picture != request.files['picture']:
            file = request.files['picture']
            if file and helper.allowed_file(file.filename):
                extension = file.filename.rsplit('.', 1)
                filename = secure_filename(file.filename)
                filename = helper.hash_filename(filename) + "." + extension[1]
                player.picture = filename
                # saves file in file system
                file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        session.add(player)
        session.commit()
        flash('Player %s Edited Successfully' % player.name)
        return redirect(url_for('showPlayers', team_id=team_id))
    return render_template('players/editplayer.html',
                           skill_levels=skill_levels,
                           player=player,
                           team=team)