from django.contrib import admin

from .models import (
    FileIndex,
    Project,
    ProjectAsset,
    ProjectContributor,
    Tag,
    TagCategory,
    TagList,
    Version,
)


@admin.register(FileIndex)
class FileIndexAdmin(admin.ModelAdmin):
    list_display = ('uuid', 'kind', 'owner', 'original_filename', 'size', 'created_at')
    search_fields = ('uuid', 'original_filename', 'stored_path')


@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ('slug', 'title', 'category', 'owner', 'created_at', 'updated_at')
    search_fields = ('slug', 'title', 'summary')
    list_filter = ('category', 'created_at')


@admin.register(Version)
class VersionAdmin(admin.ModelAdmin):
    list_display = ('project', 'version_name', 'downloads', 'created_at')
    search_fields = ('project__title', 'version_name')


@admin.register(ProjectAsset)
class ProjectAssetAdmin(admin.ModelAdmin):
    list_display = ('project', 'caption', 'uploaded_by', 'created_at')


@admin.register(ProjectContributor)
class ProjectContributorAdmin(admin.ModelAdmin):
    list_display = ('project', 'user', 'added_by', 'added_at')


@admin.register(TagCategory)
class TagCategoryAdmin(admin.ModelAdmin):
    list_display = ('slug', 'name', 'color')


@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
    list_display = ('name', 'category', 'created_by', 'created_at')
    list_filter = ('category',)
    search_fields = ('name',)


@admin.register(TagList)
class TagListAdmin(admin.ModelAdmin):
    list_display = ('project', 'tag', 'added_by', 'added_at')
    search_fields = ('project__title', 'tag__name')
