18 lines
696 B
Python
18 lines
696 B
Python
from django.contrib import admin
|
|
|
|
from .models import Task
|
|
|
|
@admin.register(Task)
|
|
class TaskAdmin(admin.ModelAdmin):
|
|
list_display = ("work_date", "title", "project", "assignee", "duration_minutes", "amount", "status")
|
|
list_filter = ("status", "project__company", "project", "work_date")
|
|
search_fields = ("title", "description", "assignee__username")
|
|
readonly_fields = ("hourly_rate", "amount", "created_by", "created_at", "updated_at")
|
|
|
|
def save_model(self, request, obj, form, change):
|
|
if not obj.created_by_id:
|
|
obj.created_by = request.user
|
|
obj.apply_current_rate()
|
|
obj.full_clean()
|
|
super().save_model(request, obj, form, change)
|