ajout d'un paneau admin
This commit is contained in:
+14
-4
@@ -12,9 +12,11 @@ from sqlalchemy import text
|
||||
from werkzeug.exceptions import HTTPException
|
||||
import markupsafe
|
||||
from dotenv import load_dotenv
|
||||
import os as _os
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Load .env from the app directory (independent of the process working directory)
|
||||
_env_path = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), '.env')
|
||||
load_dotenv(_env_path)
|
||||
|
||||
def nl2br(value):
|
||||
"""Convert newlines to HTML line breaks.
|
||||
@@ -55,11 +57,17 @@ def create_app():
|
||||
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
|
||||
if not app.config['SECRET_KEY']:
|
||||
raise RuntimeError('SECRET_KEY environment variable must be set for security')
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
|
||||
if not app.config['SQLALCHEMY_DATABASE_URI']:
|
||||
database_url = os.getenv('DATABASE_URL')
|
||||
if not database_url:
|
||||
raise RuntimeError(
|
||||
'DATABASE_URL environment variable must be set to a PostgreSQL connection string'
|
||||
)
|
||||
# Use psycopg2 driver for PostgreSQL
|
||||
if database_url.startswith('postgresql://'):
|
||||
database_url = database_url.replace('postgresql://', 'postgresql+psycopg2://', 1)
|
||||
elif database_url.startswith('postgres://'):
|
||||
database_url = database_url.replace('postgres://', 'postgresql+psycopg2://', 1)
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = database_url
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
app.config['WTF_CSRF_ENABLED'] = True
|
||||
|
||||
@@ -111,6 +119,7 @@ def create_app():
|
||||
from app.routes.teams import teams_bp
|
||||
from app.routes.matches import matches_bp
|
||||
from app.routes.team_matches import team_matches_bp
|
||||
from app.routes.admin import admin_bp
|
||||
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(tryouts_bp)
|
||||
@@ -120,6 +129,7 @@ def create_app():
|
||||
app.register_blueprint(teams_bp)
|
||||
app.register_blueprint(matches_bp)
|
||||
app.register_blueprint(team_matches_bp)
|
||||
app.register_blueprint(admin_bp)
|
||||
|
||||
# Register custom Jinja filters
|
||||
app.jinja_env.filters['nl2br'] = nl2br
|
||||
|
||||
Reference in New Issue
Block a user