updated to folders

This commit is contained in:
Ske087
2025-02-01 22:38:22 +02:00
parent 2b259af3a5
commit 6b9c3e6847
5 changed files with 19 additions and 5 deletions

18
app.py
View File

@@ -9,14 +9,18 @@ from flask_migrate import Migrate
from pdf2image import convert_from_path
import subprocess
app = Flask(__name__)
app = Flask(__name__, instance_relative_config=True)
# Set the secret key from environment variable or use a default value
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'Ana_Are_Multe_Mere-Si_Nu_Are_Pere')
# Configurare baza de date SQLite
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///dashboard.db'
# Configure the database location to be in the instance folder
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(app.instance_path, 'dashboard.db')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Ensure the instance folder exists
os.makedirs(app.instance_path, exist_ok=True)
db = SQLAlchemy(app)
bcrypt = Bcrypt(app)
@@ -376,8 +380,16 @@ def group_fullscreen(group_id):
@admin_required
def delete_player(player_id):
player = Player.query.get_or_404(player_id)
# Delete all media related to the player
media_items = Content.query.filter_by(player_id=player_id).all()
for media in media_items:
db.session.delete(media)
# Delete the player
db.session.delete(player)
db.session.commit()
return redirect(url_for('dashboard'))
@app.route('/player/add', methods=['GET', 'POST'])