from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.contrib import admin

from .models import Project, Job, Task, ProjectWorker, UsedTaskTime

UserAdmin.list_display = (
    'username', 'email', 'first_name', 'last_name',
    'is_active', 'is_superuser', 'is_staff')

admin.site.unregister(User)
admin.site.register(User, UserAdmin)


class ProjectAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'start_dt', 'end_dt', 'sortkey')
    ordering = ['sortkey']

admin.site.register(Project, ProjectAdmin)


class JobAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'sortkey', 'invalid')
    ordering = ['sortkey']

admin.site.register(Job, JobAdmin)


class TaskAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'job', 'sortkey', 'invalid')
    ordering = ['job', 'sortkey']

admin.site.register(Task, TaskAdmin)


class ProjectWorkerAdmin(admin.ModelAdmin):
    list_display = ('id', 'user', 'project', 'job', 'invalid')
    list_filter = ['user', 'project', 'job']
    ordering = ['user', 'project', 'job']


admin.site.register(ProjectWorker, ProjectWorkerAdmin)


class UsedTaskTimeAdmin(admin.ModelAdmin):
    list_display = ('id', 'taskdate', 'tasktime', 'user', 'project', 'task')
    list_filter = ['user']
    ordering = ['-id']

admin.site.register(UsedTaskTime, UsedTaskTimeAdmin)

from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.contrib import admin

from .models import Project, Job, Task, ProjectWorker, UsedTaskTime

UserAdmin.list_display = (
    'username', 'email', 'first_name', 'last_name',
    'is_active', 'is_superuser', 'is_staff')

admin.site.unregister(User)
admin.site.register(User, UserAdmin)


class ProjectAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'start_dt', 'end_dt', 'sortkey')
    list_display_links = ('id', 'name')
    ordering = ['sortkey']

admin.site.register(Project, ProjectAdmin)


class JobAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'sortkey', 'invalid')
    list_display_links = ('id', 'name')
    ordering = ['sortkey']

admin.site.register(Job, JobAdmin)


class TaskAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'job', 'sortkey', 'invalid')
    list_display_links = ('id', 'name')
    ordering = ['job', 'sortkey']

admin.site.register(Task, TaskAdmin)


class ProjectWorkerAdmin(admin.ModelAdmin):
    list_display = ('id', 'user', 'project', 'job', 'invalid')
    list_filter = ['user', 'project', 'job']
    ordering = ['user', 'project', 'job']


admin.site.register(ProjectWorker, ProjectWorkerAdmin)


class UsedTaskTimeAdmin(admin.ModelAdmin):
    list_display = ('id', 'taskdate', 'tasktime', 'user', 'project', 'task')
    list_filter = ['user']
    ordering = ['-id']

admin.site.register(UsedTaskTime, UsedTaskTimeAdmin)

add link with name column.