def get_submission(submission_id): """Get a single submission.""" database = get_db() cursor = database.execute( 'SELECT * FROM submissions WHERE ' + 'submissionid = ?', (submission_id, )) return cursor.fetchone()
def get_visible_projects(username): """Get all visible projects for user.""" database = get_db() cursor = database.execute( 'SELECT * FROM project_permissions ' + 'WHERE username = ?', (username, )) return cursor.fetchall()
def get_submissions_for_project(username, proj_id): """Get submissions for project proj_id.""" database = get_db() cursor = database.execute( 'SELECT * FROM submissions WHERE ' + 'owner = ? AND ' + 'projectid = ?', ( username, proj_id, )) return cursor.fetchall()
def create_account(username, fullname, email, file, password, password2): """Create Account.""" if password != password2: return flask.render_template('create.html') if username_exists(username): return flask.render_template('create.html') database = get_db() cursor = database.cursor() hash_password = hash_new_pass(password) print('hashed: ') print(hash_password) hash_filename = upload_file(file) cursor = cursor.execute( "INSERT INTO users (username, fullname, email, filename, password) VALUES (?, ?, ?, ?, ?)", (username, fullname, email, hash_filename, hash_password)) database.commit() session['username'] = username return redirect(url_for('show_index'))
def get_all_table(table_name): """Get all data from table specified.""" database = get_db() cursor = database.execute('SELECT * FROM ' + table_name) return cursor.fetchall()
def get_submissions(username): """Get all submissions for username.""" database = get_db() cursor = database.execute('SELECT * FROM submissions WHERE ' + 'owner = ?', (username, )) return cursor.fetchall()
def get_user(username): """Get user with username from users table.""" database = get_db() cursor = database.execute('SELECT * FROM users WHERE ' + 'username = ?', (username, )) return cursor.fetchone()