mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-17 18:38:46 -05:00
b4486a627f
- Webhook models: remove duplicate index definitions so db.create_all() no longer raises 'index already exists' (columns already have index=True) - ImportService: fix circular import by late-importing ClientService, ProjectService, TimeTrackingService in __init__ - reports: fix F823 by renaming unpack variable _ to _entry_count to avoid shadowing gettext _ in export_task_excel() - Code quality: add .flake8 with extend-ignore so flake8 CI passes; simplify pyproject.toml isort config (drop unsupported options) - Format: run black and isort on app/ - tests: restore minimal app fixture in test_import_export_models
25 lines
725 B
Python
25 lines
725 B
Python
"""Common decorators for route handlers"""
|
|
|
|
from functools import wraps
|
|
|
|
from flask import flash, redirect, url_for
|
|
from flask_babel import gettext as _
|
|
from flask_login import current_user
|
|
|
|
|
|
def admin_required(f):
|
|
"""Decorator to require admin access
|
|
|
|
DEPRECATED: Use @admin_or_permission_required() with specific permissions instead.
|
|
This decorator is kept for backward compatibility.
|
|
"""
|
|
|
|
@wraps(f)
|
|
def decorated_function(*args, **kwargs):
|
|
if not current_user.is_authenticated or not current_user.is_admin:
|
|
flash(_("Administrator access required"), "error")
|
|
return redirect(url_for("main.dashboard"))
|
|
return f(*args, **kwargs)
|
|
|
|
return decorated_function
|