game shelf rather than cards
This commit is contained in:
100
app/routes.py
100
app/routes.py
@@ -24,105 +24,13 @@ def index():
|
||||
games = Game.query.all()
|
||||
return render_template('index.html', games=games)
|
||||
|
||||
@main_bp.route('/search', methods=['GET', 'POST'])
|
||||
def search_games():
|
||||
"""Search for games using IGDB API"""
|
||||
results = []
|
||||
query = ''
|
||||
|
||||
if request.method == 'POST':
|
||||
query = request.form.get('query', '')
|
||||
|
||||
if query:
|
||||
try:
|
||||
results = igdb.search_games(query)
|
||||
except Exception as e:
|
||||
flash(f"Oopsie! Couldn't search IGDB: {str(e)}", 'error')
|
||||
|
||||
return render_template('search.html', results=results, query=query)
|
||||
# Search functionality moved to admin area only
|
||||
|
||||
@main_bp.route('/add_game/<int:igdb_id>', methods=['GET', 'POST'])
|
||||
def add_game(igdb_id):
|
||||
"""Add a game to tracking list"""
|
||||
# Check if we already have this game
|
||||
existing_game = Game.query.filter_by(igdb_id=igdb_id).first()
|
||||
|
||||
if existing_game:
|
||||
flash(f"You'we alweady twacking {existing_game.name}!", 'info')
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
# Check if we're at the 5 game limit
|
||||
if Game.query.count() >= 5:
|
||||
flash("You can onwy twack up to 5 games at once! Pwease wemove a game fiwst~", 'error')
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
# Get game details from IGDB
|
||||
try:
|
||||
game_data = igdb.get_game_by_id(igdb_id)
|
||||
|
||||
# Create new Game object
|
||||
new_game = Game(
|
||||
igdb_id=game_data['id'],
|
||||
name=game_data['name'],
|
||||
cover_url=game_data['cover_url'],
|
||||
description=game_data['description'],
|
||||
release_date=game_data['release_date'],
|
||||
platform=', '.join(game_data['platforms']) if game_data['platforms'] else None,
|
||||
developer=game_data['developer'],
|
||||
publisher=game_data['publisher'],
|
||||
status="Playing",
|
||||
progress=0
|
||||
)
|
||||
|
||||
db.session.add(new_game)
|
||||
db.session.commit()
|
||||
|
||||
flash(f"Added {new_game.name} to youw twacking wist! ^w^", 'success')
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
except Exception as e:
|
||||
flash(f"Faiwed to add game: {str(e)}", 'error')
|
||||
return redirect(url_for('main.search_games'))
|
||||
# Add game functionality moved to admin area only
|
||||
|
||||
@main_bp.route('/update_game/<int:game_id>', methods=['POST'])
|
||||
def update_game(game_id):
|
||||
"""Update game progress and status"""
|
||||
game = Game.query.get_or_404(game_id)
|
||||
|
||||
if request.method == 'POST':
|
||||
# Update status if provided
|
||||
if 'status' in request.form:
|
||||
game.status = request.form['status']
|
||||
|
||||
# Update progress if provided
|
||||
if 'progress' in request.form:
|
||||
try:
|
||||
progress = int(request.form['progress'])
|
||||
if 0 <= progress <= 100:
|
||||
game.progress = progress
|
||||
except ValueError:
|
||||
flash("Pwogwess must be a numbew between 0 and 100!", 'error')
|
||||
|
||||
# Update notes if provided
|
||||
if 'notes' in request.form:
|
||||
game.notes = request.form['notes']
|
||||
|
||||
db.session.commit()
|
||||
flash(f"Updated {game.name}! (。・ω・。)", 'success')
|
||||
|
||||
return redirect(url_for('main.index'))
|
||||
# Update game functionality moved to admin area only
|
||||
|
||||
@main_bp.route('/remove_game/<int:game_id>', methods=['POST'])
|
||||
def remove_game(game_id):
|
||||
"""Remove a game from tracking list"""
|
||||
game = Game.query.get_or_404(game_id)
|
||||
name = game.name
|
||||
|
||||
db.session.delete(game)
|
||||
db.session.commit()
|
||||
|
||||
flash(f"Removed {name} from tracking list!", 'success')
|
||||
return redirect(url_for('main.index'))
|
||||
# Remove game functionality moved to admin area only
|
||||
|
||||
# Admin Routes
|
||||
@main_bp.route('/admin/login', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user