diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc index d541a9d..6fa249e 100644 Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ diff --git a/app.py b/app.py index f73752d..438d9d8 100644 --- a/app.py +++ b/app.py @@ -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']) diff --git a/dashboard.db b/dashboard.db deleted file mode 100644 index 40690eb..0000000 Binary files a/dashboard.db and /dev/null differ diff --git a/docker-compose.yml b/docker-compose.yml index 18d11df..c58d452 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ - +version: '3.8' services: web: - image: digi_server:latest + image: digi-server:latest ports: - "7100:5000" environment: @@ -13,4 +13,6 @@ services: - SECRET_KEY=Ma_Duc_Dupa_Merele_Lui_Ana volumes: - .:/app + - ./data/db:/app/instance + - ./data/static:/app/static/uploads command: sh -c "python clear_db.py && python init_db.py && gunicorn -w 4 -b 0.0.0.0:5000 app:app" \ No newline at end of file diff --git a/instance/dashboard.db b/instance/dashboard.db index adbb694..f4dbada 100644 Binary files a/instance/dashboard.db and b/instance/dashboard.db differ