from django.contrib import admin
from django.utils.html import format_html
from django.urls import reverse
from django.db.models import Count

from .models import (
    Parameter,
    Customer,
    Simulation,
    BlogCategory, 
    BlogPost, 
    ProjectCategory, 
    Project, 
    ProjectImage, 
    ProjectVideo,
    DashboardProject,
    ProjectActivity,
    ActivityImage,
    ActivityVideo,
    ActivityFile,
    Testimonial,
    ProductCategory,
    Product,
    ProjectPhase,
    ProjectSubphase,
    Decompte,
    Invoice,
    ProjectPayment,
    ProjectRetention,
    ProjectDocument,
    SavWarranty,
    SavTicket,
    SavRepairPV,
)


@admin.register(Parameter)
class ParameterAdmin(admin.ModelAdmin):
    list_display = ('name', 'phone', 'email', 'createdAt')
    search_fields = ('name', 'email')


@admin.register(Customer)
class CustomerAdmin(admin.ModelAdmin):
    list_display = (
        'full_name', 
        'email', 
        'phone', 
        'simulation_count',
        'last_simulation_date',
        'created_at'
    )
    list_filter = (
        'created_at',
    )
    search_fields = (
        'full_name',
        'email',
        'phone'
    )
    readonly_fields = (
        'simulation_count',
        'last_simulation_date',
        'created_at',
        'updated_at'
    )
    ordering = ('-created_at',)


@admin.register(Simulation)
class SimulationAdmin(admin.ModelAdmin):
    list_display = (
        'id',
        'customer_name',
        'project_type',
        'standing',
        'niveau',
        'region',
        'cout_total',
        'status',
        'created_at'
    )
    list_filter = (
        'status',
        'project_type',
        'standing',
        'niveau',
        'region',
        'ascenseur',
        'created_at',
    )
    search_fields = (
        'customer__full_name',
        'customer__email',
        'id'
    )
    readonly_fields = (
        'created_at',
        'updated_at',
        'ip_address',
        'user_agent'
    )
    ordering = ('-created_at',)
    date_hierarchy = 'created_at'
    
    def customer_name(self, obj):
        return obj.customer.full_name
    customer_name.short_description = 'Client'
    customer_name.admin_order_field = 'customer__full_name'

    def get_queryset(self, request):
        return super().get_queryset(request).select_related('customer')

    actions = ['mark_as_quote_sent']

    def mark_as_quote_sent(self, request, queryset):
        updated = queryset.update(status='QUOTE_SENT')
        self.message_user(
            request,
            f'{updated} simulation(s) marquée(s) comme "Devis envoyé".'
        )
    mark_as_quote_sent.short_description = "Marquer comme 'Devis envoyé'"


# ========================================
# ADMINISTRATION BLOG
# ========================================

@admin.register(BlogCategory)
class BlogCategoryAdmin(admin.ModelAdmin):
    list_display = ['name', 'slug', 'color', 'created_at']
    list_filter = ['created_at']
    search_fields = ['name', 'description']
    prepopulated_fields = {'slug': ('name',)}
    fields = ['name', 'slug', 'description', 'color']

class BlogPostAdmin(admin.ModelAdmin):
    list_display = ['title', 'author', 'category', 'status', 'featured', 'views_count', 'published_at', 'created_at']
    list_filter = ['status', 'featured', 'category', 'created_at', 'published_at']
    search_fields = ['title', 'excerpt', 'content', 'tags']
    prepopulated_fields = {'slug': ('title',)}
    readonly_fields = ['views_count', 'created_at', 'updated_at']
    filter_horizontal = []
    
    fieldsets = (
        ('Contenu', {
            'fields': ('title', 'slug', 'excerpt', 'content', 'featured_image')
        }),
        ('Métadonnées', {
            'fields': ('category', 'author', 'tags', 'meta_description')
        }),
        ('Publication', {
            'fields': ('status', 'featured', 'published_at')
        }),
        ('Statistiques', {
            'fields': ('views_count', 'created_at', 'updated_at'),
            'classes': ['collapse']
        })
    )
    
    def save_model(self, request, obj, form, change):
        if not change:  # Si c'est un nouvel objet
            obj.author = request.user
        super().save_model(request, obj, form, change)

admin.site.register(BlogPost, BlogPostAdmin)

# ========================================
# ADMINISTRATION PROJETS
# ========================================

@admin.register(ProjectCategory)
class ProjectCategoryAdmin(admin.ModelAdmin):
    list_display = ['name', 'slug', 'icon', 'created_at']
    list_filter = ['created_at']
    search_fields = ['name', 'description']
    prepopulated_fields = {'slug': ('name',)}
    fields = ['name', 'slug', 'description', 'icon']

class ProjectImageInline(admin.StackedInline):
    model = ProjectImage
    extra = 1  # Un formulaire vide pour faciliter l'ajout
    max_num = 10
    can_delete = True
    fields = ['image', 'image_preview']
    readonly_fields = ['image_preview']
    
    def image_preview(self, obj):
        if obj.image:
            return format_html(
                '<img src="{}" style="max-width: 200px; max-height: 150px; border-radius: 8px;" />',
                obj.image.url
            )
        return "Aucune image"
    image_preview.short_description = "Aperçu"

class ProjectVideoInline(admin.StackedInline):
    model = ProjectVideo
    extra = 0  # Pas de formulaire vide par défaut
    max_num = 5
    can_delete = True
    fields = ['video_file', 'video_url', 'video_preview']
    readonly_fields = ['video_preview']
    
    def video_preview(self, obj):
        if obj.video_file:
            return format_html(
                '<video controls style="max-width: 300px; max-height: 200px;"><source src="{}" type="video/mp4"></video>',
                obj.video_file.url
            )
        elif obj.video_url:
            return format_html(
                '<p><strong>URL:</strong> <a href="{}" target="_blank">{}</a></p>',
                obj.video_url, obj.video_url
            )
        return "Aucune vidéo"
    video_preview.short_description = "Aperçu vidéo"

@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ['title', 'category', 'location', 'status', 'featured', 'published', 'views_count', 'completed_date', 'created_at']
    list_filter = ['status', 'featured', 'published', 'category', 'completed_date', 'created_at']
    search_fields = ['title', 'description', 'location', 'client_name']
    prepopulated_fields = {'slug': ('title',)}
    readonly_fields = ['views_count', 'created_at', 'updated_at', 'main_image_preview']
    inlines = [ProjectImageInline, ProjectVideoInline]
    
    def main_image_preview(self, obj):
        if obj.main_image:
            return format_html(
                '<img src="{}" style="max-width: 300px; max-height: 200px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);" />',
                obj.main_image.url
            )
        return "Aucune image principale"
    main_image_preview.short_description = "Aperçu de l'image principale"
    
    fieldsets = (
        ('Informations générales', {
            'fields': ('title', 'slug', 'short_description', 'category'),
            'classes': ['wide']
        }),
        ('Image principale', {
            'fields': ('main_image', 'main_image_preview'),
            'classes': ['wide']
        }),
        ('Description complète', {
            'fields': ('description',),
            'classes': ['wide']
        }),
        ('Détails du projet', {
            'fields': (
                ('location', 'client_name'),
                ('surface_built', 'surface_land'),
                ('floors_count', 'rooms_count')
            ),
            'classes': ['wide']
        }),
        ('Dates et budget', {
            'fields': (
                ('start_date', 'completed_date'),
                'budget'
            ),
            'classes': ['wide']
        }),
        ('Statut et visibilité', {
            'fields': (
                ('status', 'featured'),
                'published'
            ),
            'classes': ['wide']
        }),
        ('Statistiques', {
            'fields': ('views_count', 'created_at', 'updated_at'),
            'classes': ['collapse', 'wide']
        })
    )
    
    class Media:
        css = {
            'all': ('admin/css/custom_admin.css',)
        }
        js = ('admin/js/custom_admin.js',)

@admin.register(ProjectImage)
class ProjectImageAdmin(admin.ModelAdmin):
    list_display = ['project', 'title', 'image_thumbnail', 'order', 'created_at']
    list_filter = ['created_at', 'project']
    search_fields = ['title', 'description', 'project__title']
    list_editable = ['order']
    readonly_fields = ['image_preview']
    
    def image_thumbnail(self, obj):
        if obj.image:
            return format_html(
                '<img src="{}" style="width: 50px; height: 50px; object-fit: cover; border-radius: 4px;" />',
                obj.image.url
            )
        return "Pas d'image"
    image_thumbnail.short_description = "Aperçu"
    
    def image_preview(self, obj):
        if obj.image:
            return format_html(
                '<img src="{}" style="max-width: 400px; max-height: 300px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);" />',
                obj.image.url
            )
        return "Aucune image"
    image_preview.short_description = "Aperçu de l'image"
    
    fieldsets = (
        ('Image', {
            'fields': ('image', 'image_preview'),
            'classes': ['wide']
        }),
        ('Informations', {
            'fields': ('project', 'title', 'description', 'order'),
            'classes': ['wide']
        }),
    )

@admin.register(ProjectVideo)
class ProjectVideoAdmin(admin.ModelAdmin):
    list_display = ['project', 'title', 'video_type', 'thumbnail_small', 'duration', 'order', 'created_at']
    list_filter = ['video_type', 'created_at', 'project']
    search_fields = ['title', 'description', 'project__title']
    list_editable = ['order']
    readonly_fields = ['video_preview', 'thumbnail_preview']
    
    def thumbnail_small(self, obj):
        if obj.thumbnail:
            return format_html(
                '<img src="{}" style="width: 50px; height: 50px; object-fit: cover; border-radius: 4px;" />',
                obj.thumbnail.url
            )
        return "Pas de miniature"
    thumbnail_small.short_description = "Miniature"
    
    def video_preview(self, obj):
        if obj.video_file:
            return format_html(
                '<video controls style="max-width: 400px; max-height: 300px; border-radius: 8px;"><source src="{}" type="video/mp4"></video>',
                obj.video_file.url
            )
        elif obj.video_url:
            return format_html(
                '<p><strong>URL:</strong> <a href="{}" target="_blank">{}</a></p>',
                obj.video_url, obj.video_url
            )
        return "Aucune vidéo"
    video_preview.short_description = "Aperçu vidéo"
    
    def thumbnail_preview(self, obj):
        if obj.thumbnail:
            return format_html(
                '<img src="{}" style="max-width: 200px; max-height: 150px; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);" />',
                obj.thumbnail.url
            )
        return "Aucune miniature"
    thumbnail_preview.short_description = "Aperçu miniature"
    
    fieldsets = (
        ('Informations générales', {
            'fields': ('project', 'title', 'description', 'order'),
            'classes': ['wide']
        }),
        ('Fichier vidéo', {
            'fields': ('video_file', 'video_preview'),
            'classes': ['wide']
        }),
        ('URL vidéo externe', {
            'fields': ('video_url', 'video_type'),
            'classes': ['wide']
        }),
        ('Miniature et métadonnées', {
            'fields': ('thumbnail', 'thumbnail_preview', 'duration'),
            'classes': ['wide']
        }),
    )


# ================================
# ADMIN POUR NOUVEAUX MODÈLES DASHBOARD
# ================================

class ActivityImageInline(admin.StackedInline):
    model = ActivityImage
    extra = 0
    fields = ('image', 'title', 'description', 'order')

class ActivityVideoInline(admin.StackedInline):
    model = ActivityVideo
    extra = 0
    fields = ('title', 'video_type', 'video_file', 'video_url', 'description', 'order')

class ActivityFileInline(admin.StackedInline):
    model = ActivityFile
    extra = 0
    fields = ('title', 'file', 'description', 'uploaded_by')
    readonly_fields = ('uploaded_by',)

    def get_readonly_fields(self, request, obj=None):
        if obj:  # Editing
            return self.readonly_fields + ('uploaded_by',)
        return self.readonly_fields

@admin.register(ProjectActivity)
class ProjectActivityAdmin(admin.ModelAdmin):
    list_display = [
        'title', 
        'project', 
        'activity_type', 
        'billing_type',
        'budget_amount',
        'is_completed', 
        'is_active',
        'due_date', 
        'assigned_to', 
        'created_by',
        'created_at'
    ]
    list_filter = [
        'activity_type', 
        'billing_type',
        'is_completed', 
        'is_active',
        'created_at', 
        'due_date',
        'project__status'
    ]
    search_fields = [
        'title', 
        'description', 
        'project__title',
        'created_by__user__username',
        'assigned_to__user__username'
    ]
    readonly_fields = ['created_at', 'updated_at']
    inlines = [ActivityImageInline, ActivityVideoInline, ActivityFileInline]
    
    fieldsets = (
        ('Informations générales', {
            'fields': ('project', 'title', 'activity_type', 'description', 'parent')
        }),
        ('Assignation et statut', {
            'fields': ('assigned_to', 'is_completed', 'is_active', 'due_date', 'priority')
        }),
        ('Facturation & Budget', {
            'fields': ('billing_type', 'budget_amount')
        }),
        ('Métadonnées', {
            'fields': ('created_by', 'created_at', 'updated_at'),
            'classes': ('collapse',)
        })
    )

    def save_model(self, request, obj, form, change):
        if not change:  # Création
            obj.created_by = request.user.cuser
        super().save_model(request, obj, form, change)


class ProjectActivityInline(admin.StackedInline):
    model = ProjectActivity
    extra = 0
    fields = ('title', 'activity_type', 'is_completed', 'due_date', 'assigned_to')
    show_change_link = True


class ProjectSubphaseInline(admin.StackedInline):
    model = ProjectSubphase
    extra = 0
    fields = ('name', 'type', 'order', 'weight', 'progress_percent', 'level_index', 'level_label', 'start_planned', 'end_planned', 'start_actual', 'end_actual')
    show_change_link = True


@admin.register(ProjectPhase)
class ProjectPhaseAdmin(admin.ModelAdmin):
    list_display = ('project', 'order', 'name', 'status', 'weight', 'progress_percent')
    list_filter = ('status', 'order', 'project__client')
    search_fields = ('name', 'project__title')
    list_editable = ('status', 'weight', 'progress_percent')
    inlines = [ProjectSubphaseInline]
    fieldsets = (
        (None, {
            'fields': ('project', 'order', 'name', 'status', 'weight', 'progress_percent')
        }),
        ('Planification', {
            'fields': (('start_planned', 'end_planned'), ('start_actual', 'end_actual'))
        }),
        ('Métadonnées', {
            'fields': ('created_at', 'updated_at'),
            'classes': ('collapse',)
        }),
    )
    readonly_fields = ('created_at', 'updated_at')


@admin.register(ProjectSubphase)
class ProjectSubphaseAdmin(admin.ModelAdmin):
    list_display = ('phase', 'name', 'type', 'order', 'weight', 'progress_percent', 'level_label')
    list_filter = ('type', 'phase__order', 'phase__project')
    search_fields = ('name', 'phase__name', 'phase__project__title')
    list_editable = ('order', 'weight', 'progress_percent')

@admin.register(DashboardProject)
class DashboardProjectAdmin(admin.ModelAdmin):
    list_display = [
        'title',
        'client',
        'category',
        'project_type',
        'status',
        'activities_count',
        'completion_percentage',
        'start_date',
        'end_date',
        'created_by',
        'created_at'
    ]
    list_filter = [
        'status',
        'created_at',
        'start_date',
        'end_date',
        'category',
        'project_type',
        'client__user__is_active'
    ]
    search_fields = [
        'title',
        'description',
        'client__user__username',
        'client__user__first_name',
        'client__user__last_name'
    ]
    readonly_fields = [
        'created_at', 
        'updated_at', 
        'activities_count', 
        'completion_percentage'
    ]
    inlines = [ProjectActivityInline]
    filter_horizontal = ['assigned_technicians']
    
    fieldsets = (
        ('Informations générales', {
            'fields': ('title', 'description', 'client', 'category', 'project_type')
        }),
        ('Équipe et assignation', {
            'fields': ('assigned_technicians',)
        }),
        ('Planification', {
            'fields': ('status', 'start_date', 'end_date', 'budget')
        }),
        ('Statistiques', {
            'fields': ('activities_count', 'completion_percentage'),
            'classes': ('collapse',)
        }),
        ('Métadonnées', {
            'fields': ('created_by', 'created_at', 'updated_at'),
            'classes': ('collapse',)
        })
    )

    def save_model(self, request, obj, form, change):
        if not change:  # Création
            obj.created_by = request.user.cuser
        super().save_model(request, obj, form, change)

    def activities_count(self, obj):
        return obj.activities_count
    activities_count.short_description = "Nb. activités"

    def completion_percentage(self, obj):
        percentage = obj.completion_percentage
        color = 'green' if percentage >= 80 else 'orange' if percentage >= 50 else 'red'
        return format_html(
            '<span style="color: {};">{} %</span>',
            color,
            percentage
        )
    completion_percentage.short_description = "Progression"


@admin.register(Decompte)
class DecompteAdmin(admin.ModelAdmin):
    list_display = ('project', 'label', 'amount', 'status', 'date', 'phase', 'subphase')
    list_filter = ('status', 'date', 'project')
    search_fields = ('label', 'project__title')
    list_editable = ('status',)
    autocomplete_fields = ('project', 'phase', 'subphase')


@admin.register(Invoice)
class InvoiceAdmin(admin.ModelAdmin):
    list_display = ('number', 'project', 'amount', 'status', 'date', 'due_date', 'paid_date')
    list_filter = ('status', 'date', 'due_date', 'paid_date', 'project')
    search_fields = ('number', 'project__title')
    list_editable = ('status',)
    autocomplete_fields = ('project', 'decompte')


@admin.register(ProjectPayment)
class ProjectPaymentAdmin(admin.ModelAdmin):
    list_display = ('project', 'type', 'amount', 'date', 'method', 'reference')
    list_filter = ('type', 'method', 'date', 'project')
    search_fields = ('project__title', 'reference')
    autocomplete_fields = ('project', 'decompte', 'invoice')


@admin.register(ProjectRetention)
class ProjectRetentionAdmin(admin.ModelAdmin):
    list_display = ('project', 'rate_percent', 'amount_held', 'is_released', 'release_date')
    list_editable = ('rate_percent', 'is_released')
    autocomplete_fields = ('project',)


@admin.register(ProjectDocument)
class ProjectDocumentAdmin(admin.ModelAdmin):
    list_display = ('project', 'title', 'doc_type', 'is_public', 'version', 'created_at')
    list_filter = ('doc_type', 'is_public', 'created_at', 'project')
    search_fields = ('title', 'project__title', 'tags')
    list_editable = ('is_public',)
    autocomplete_fields = ('project', 'phase', 'subphase', 'previous_version')


@admin.register(SavWarranty)
class SavWarrantyAdmin(admin.ModelAdmin):
    list_display = ('project', 'start_date', 'end_date')
    autocomplete_fields = ('project',)


@admin.register(SavTicket)
class SavTicketAdmin(admin.ModelAdmin):
    list_display = ('project', 'title', 'status', 'priority', 'created_at', 'assigned_to')
    list_filter = ('status', 'priority', 'created_at', 'project')
    search_fields = ('title', 'project__title')
    list_editable = ('status', 'priority')
    autocomplete_fields = ('project', 'opened_by', 'assigned_to')


@admin.register(SavRepairPV)
class SavRepairPVAdmin(admin.ModelAdmin):
    list_display = ('ticket', 'date', 'signed_by_client', 'signed_by_staff')
    list_filter = ('date', 'ticket__project')
    search_fields = ('ticket__title', 'ticket__project__title')
    autocomplete_fields = ('ticket',)

@admin.register(ActivityImage)
class ActivityImageAdmin(admin.ModelAdmin):
    list_display = ['activity', 'title', 'image_thumbnail', 'order', 'created_at']
    list_filter = ['created_at', 'activity__project']
    search_fields = ['title', 'description', 'activity__title']
    
    def image_thumbnail(self, obj):
        if obj.image:
            return format_html(
                '<img src="{}" style="max-width: 100px; max-height: 75px; border-radius: 4px;" />',
                obj.image.url
            )
        return "Pas d'image"
    image_thumbnail.short_description = "Aperçu"

@admin.register(ActivityVideo)
class ActivityVideoAdmin(admin.ModelAdmin):
    list_display = ['activity', 'title', 'video_type', 'order', 'created_at']
    list_filter = ['video_type', 'created_at', 'activity__project']
    search_fields = ['title', 'description', 'activity__title']

@admin.register(ActivityFile)
class ActivityFileAdmin(admin.ModelAdmin):
    list_display = ['activity', 'title', 'file_extension', 'human_readable_size', 'uploaded_by', 'created_at']
    list_filter = ['created_at', 'activity__project', 'activity__activity_type']
    search_fields = ['title', 'description', 'activity__title']
    readonly_fields = ['file_size', 'uploaded_by', 'created_at']

    def save_model(self, request, obj, form, change):
        if not change:  # Création
            obj.uploaded_by = request.user.cuser
        super().save_model(request, obj, form, change)


@admin.register(Testimonial)
class TestimonialAdmin(admin.ModelAdmin):
    list_display = (
        'author',
        'role', 
        'quote_preview',
        'photo_thumbnail',
        'is_active',
        'order',
        'created_at'
    )
    list_filter = (
        'is_active',
        'created_at'
    )
    search_fields = (
        'author',
        'role',
        'quote'
    )
    list_editable = (
        'is_active',
        'order'
    )
    ordering = ('order', '-created_at')
    
    fieldsets = (
        (None, {
            'fields': ('author', 'role', 'quote')
        }),
        ('Médias', {
            'fields': ('photo',)
        }),
        ('Options d\'affichage', {
            'fields': ('is_active', 'order')
        }),
    )

    def quote_preview(self, obj):
        """Aperçu du témoignage (tronqué)"""
        if len(obj.quote) > 60:
            return f"{obj.quote[:60]}..."
        return obj.quote
    quote_preview.short_description = "Témoignage"

    def photo_thumbnail(self, obj):
        """Miniature de la photo"""
        if obj.photo:
            return format_html(
                '<img src="{}" style="max-width: 50px; max-height: 50px; border-radius: 50%; object-fit: cover;" />',
                obj.photo.url
            )
        return "Pas de photo"
    photo_thumbnail.short_description = "Photo"


# ========================================
# ADMIN BOUTIQUE
# ========================================

@admin.register(ProductCategory)
class ProductCategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'order', 'is_active', 'created_at')
    list_editable = ('order', 'is_active')
    search_fields = ('name', 'description')
    list_filter = ('is_active', 'created_at')
    prepopulated_fields = {'slug': ('name',)}
    readonly_fields = ('image_preview', 'created_at', 'updated_at')

    fields = (
        'name', 'slug', 'description', 'icon', 'image', 'image_preview', 'order', 'is_active'
    )

    def image_preview(self, obj):
        if obj.image:
            return format_html('<img src="{}" style="max-width:160px; border-radius:8px;"/>', obj.image.url)
        return '—'
    image_preview.short_description = 'Aperçu'


@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    list_display = ('name', 'category', 'price_display', 'currency', 'stock', 'is_available', 'is_featured', 'status', 'created_at')
    list_filter = ('status', 'is_featured', 'category', 'created_at')
    search_fields = ('name', 'description', 'short_description')
    list_editable = ('stock', 'is_featured', 'status')
    prepopulated_fields = {'slug': ('name',)}
    readonly_fields = ('image_preview', 'created_at', 'updated_at')
    fieldsets = (
        ('Informations produit', {
            'fields': ('name', 'slug', 'category', 'short_description', 'description')
        }),
        ('Médias', {
            'fields': ('image', 'image_preview')
        }),
        ('Prix & Stock', {
            'fields': (('price', 'currency'), 'stock')
        }),
        ('Statut & Mise en avant', {
            'fields': ('status', 'is_featured')
        }),
        ('WhatsApp', {
            'fields': ('whatsapp_message_template',)
        }),
        ('Métadonnées', {
            'fields': ('created_at', 'updated_at'),
            'classes': ('collapse',)
        })
    )

    def image_preview(self, obj):
        if obj.image:
            return format_html('<img src="{}" style="max-width:220px; border-radius:12px; box-shadow:0 2px 8px rgba(0,0,0,.15);"/>', obj.image.url)
        return '—'
    image_preview.short_description = 'Aperçu'

    def price_display(self, obj):
        return f"{int(obj.price):,}".replace(',', ' ')
    price_display.short_description = 'Prix'


# Configuration globale de l'admin
admin.site.site_header = "Administration ECOLUX"
admin.site.site_title = "ECOLUX Admin"
admin.site.index_title = "Tableau de bord ECOLUX"

