# Utils package initialization
from .permissions import user_has_permission, get_user_permissions
from .event_logger import log_event, get_user_events, get_room_events, get_recent_events, get_events_by_type, get_events_by_date_range
from .notification import create_notification, get_user_notifications, mark_notification_read, mark_all_notifications_read, get_unread_count, delete_notification, delete_old_notifications
from .path_utils import clean_path, secure_file_path
from .time_utils import timeago, format_datetime, parse_datetime
from functools import wraps
from flask import flash, redirect, url_for
from flask_login import current_user

def admin_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if not current_user.is_authenticated or not current_user.is_admin:
            flash('You do not have permission to access this page.', 'error')
            return redirect(url_for('main.dashboard'))
        return f(*args, **kwargs)
    return decorated_function

__all__ = [
    'user_has_permission',
    'get_user_permissions',
    'log_event',
    'get_user_events',
    'get_room_events',
    'get_recent_events',
    'get_events_by_type',
    'get_events_by_date_range',
    'create_notification',
    'get_user_notifications',
    'mark_notification_read',
    'mark_all_notifications_read',
    'get_unread_count',
    'delete_notification',
    'delete_old_notifications',
    'clean_path',
    'secure_file_path',
    'timeago',
    'format_datetime',
    'parse_datetime'
] 