"""
Django Feature RBAC - Group-based Role-Based Access Control with Onboarding
"""

# Core permission functions
from ldc_dashboard_rbac.permissions import (
    user_has_feature_permission,
    get_user_features,
    is_superadmin_user,
    is_admin_user,
    get_rbac_config,
)

# Decorators for Django views
from ldc_dashboard_rbac.decorators import (
    feature_required,
    feature_permission_required,  # alias for backward compatibility
    admin_required,
    superadmin_required,
)

# DRF permissions
try:
    from ldc_dashboard_rbac.drf_permissions import (
        HasFeaturePermission,
        IsFeatureAdmin,  # Fix: was IsAdminOrSuperAdmin
        IsSuperAdmin,
        DynamicFeaturePermission,  # Add: was missing
    )
except ImportError:
    # DRF not installed
    pass

# Onboarding views
from ldc_dashboard_rbac.onboarding import (
    RegistrationView,           # Fix: actual class name
    AdminRegistrationView,      # ✅ Correct
    ResetPasswordView,          # Fix: actual class name  
    SetPasswordView,            # ✅ Correct
    UserApprovalView,           # ✅ Correct
)

# Abstract models
from ldc_dashboard_rbac.models import (
    AbstractFeature,
    AbstractDashboardUser,
    AbstractGroup,
    AbstractUserGroupMembership,
    AbstractGroupFeaturePermission,
    AbstractPasswordResetToken,
    AbstractUserGroup,  # Backward compatibility alias
)

# Utility functions
from ldc_dashboard_rbac.utils import (
    send_email,
    sync_features_from_urls,
    get_user_permission_summary,
    validate_rbac_configuration,
    export_rbac_configuration,
    import_rbac_configuration,
)

__version__ = '1.0.2'
__author__ = 'Nishant Baruah'
__email__ = 'nishant.baruah@lendenclub.com'

# Default Django app configuration
default_app_config = 'ldc_dashboard_rbac.apps.LdcDashboardRbacConfig'

# Backward compatibility
feature_permission_required = feature_required

__all__ = [
    # Permission functions
    'user_has_feature_permission',
    'get_user_features', 
    'is_superadmin_user',
    'is_admin_user',
    'get_rbac_config',
    
    # Decorators
    'feature_required',
    'feature_permission_required',
    'admin_required',
    'superadmin_required',
    
    # DRF permissions (if available)
    'HasFeaturePermission',
    'IsFeatureAdmin',  # Fix: correct name
    'IsSuperAdmin',
    'DynamicFeaturePermission',  # Add: was missing
    
    # Onboarding views
    'RegistrationView',         # Fix: actual class name
    'AdminRegistrationView',    # ✅ Correct
    'ResetPasswordView',        # Fix: actual class name
    'SetPasswordView',          # ✅ Correct
    'UserApprovalView',         # ✅ Correct
    
    # Abstract models
    'AbstractFeature',
    'AbstractDashboardUser',
    'AbstractGroup',
    'AbstractUserGroupMembership',
    'AbstractGroupFeaturePermission',
    'AbstractPasswordResetToken',
    'AbstractUserGroup',
    
    # Utility functions
    'send_email',
    'sync_features_from_urls',
    'get_user_permission_summary',
    'validate_rbac_configuration',
    'export_rbac_configuration',
    'import_rbac_configuration',
]