updated to folders
This commit is contained in:
18
app.py
18
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'])
|
||||
|
||||
Reference in New Issue
Block a user