def list_benchmarks(database, user_id=None): """ Lists all benchmarks that the currently logged in user submitted. """ db = models.get_database(database) or abort(404) uploaded_files = {} directory = os.path.join(config.UPLOAD_FOLDER, database) for file in os.listdir(directory): if os.path.isdir(os.path.join(directory, file)): for user_dir in os.listdir(os.path.join(directory, file)): if (is_admin() and user_id and user_dir == str(user_id)) or ( not user_id and user_dir == str(g.User.idUser)): if not file in uploaded_files: uploaded_files[file] = list() files = os.listdir(os.path.join(directory, file, user_dir)) files_full_path = [ os.path.join(directory, file, user_dir, f) for f in files ] uploaded_files[file] += zip(files, [ time.ctime(os.path.getmtime(f)) for f in files_full_path ]) return render('/accounts/list_benchmarks.html', database=database, db=db, uploaded_files=uploaded_files, user_id=user_id)
def list_solvers(database, user_id=None): """ Lists all solvers that the user submitted to the database """ db = models.get_database(database) or abort(404) user = db.session.query(db.User).get(user_id or g.User.idUser) or abort(404) if is_admin() and user_id: solvers = db.session.query(db.Solver).filter_by(User_idUser=user_id).all() else: if user_id and g.User.idUser != user_id: abort(401) solvers = db.session.query(db.Solver).filter_by(user=g.User).all() return render('/accounts/list_solvers.html', database=database, user=user, solvers=solvers, db=db)
def list_benchmarks(database, user_id=None): """ Lists all benchmarks that the currently logged in user submitted. """ db = models.get_database(database) or abort(404) uploaded_files = {} directory = os.path.join(config.UPLOAD_FOLDER, database) for file in os.listdir(directory): if os.path.isdir(os.path.join(directory, file)): for user_dir in os.listdir(os.path.join(directory, file)): if (is_admin() and user_id and user_dir == str(user_id)) or ( not user_id and user_dir == str(g.User.idUser)): if not file in uploaded_files: uploaded_files[file] = list() files = os.listdir(os.path.join(directory, file, user_dir)) files_full_path = [os.path.join(directory, file, user_dir, f) for f in files] uploaded_files[file] += zip(files, [time.ctime(os.path.getmtime(f)) for f in files_full_path]) return render('/accounts/list_benchmarks.html', database=database, db=db, uploaded_files=uploaded_files, user_id=user_id)
def list_solvers(database, user_id=None): """ Lists all solvers that the user submitted to the database """ db = models.get_database(database) or abort(404) user = db.session.query(db.User).get(user_id or g.User.idUser) or abort(404) if is_admin() and user_id: solvers = db.session.query( db.Solver).filter_by(User_idUser=user_id).all() else: if user_id and g.User.idUser != user_id: abort(401) solvers = db.session.query(db.Solver).filter_by(user=g.User).all() return render('/accounts/list_solvers.html', database=database, user=user, solvers=solvers, db=db)