from django.contrib import admin
from .models import Project, ProjectMember, ProjectAttachment, ProjectStageLog


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ['name', 'client_name', 'pm', 'status', 'stage', 'approved_budget', 'created_at']
    list_filter = ['status', 'stage', 'service_type']
    search_fields = ['name', 'client_name']


@admin.register(ProjectMember)
class ProjectMemberAdmin(admin.ModelAdmin):
    list_display = ['user', 'project', 'role_on_project']


@admin.register(ProjectAttachment)
class ProjectAttachmentAdmin(admin.ModelAdmin):
    list_display = ['file_name', 'project', 'uploaded_by', 'uploaded_at']


@admin.register(ProjectStageLog)
class ProjectStageLogAdmin(admin.ModelAdmin):
    list_display = ['project', 'from_stage', 'to_stage', 'changed_by', 'timestamp']
    readonly_fields = ['project', 'from_stage', 'to_stage', 'note', 'changed_by', 'timestamp']
