54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
from django.contrib import admin
|
|
|
|
from .models import (
|
|
AllocationReminder,
|
|
AllocationRevision,
|
|
DailyAllocation,
|
|
Project,
|
|
ProjectEvent,
|
|
ProjectExternalBinding,
|
|
ProjectMembership,
|
|
ProjectStage,
|
|
)
|
|
|
|
|
|
class MembershipInline(admin.TabularInline):
|
|
model = ProjectMembership
|
|
extra = 0
|
|
|
|
|
|
class StageInline(admin.TabularInline):
|
|
model = ProjectStage
|
|
extra = 0
|
|
|
|
|
|
@admin.register(Project)
|
|
class ProjectAdmin(admin.ModelAdmin):
|
|
list_display = ["name", "manager", "status", "starts_on", "ends_on"]
|
|
list_filter = ["status"]
|
|
search_fields = ["name", "customer"]
|
|
inlines = [MembershipInline, StageInline]
|
|
|
|
|
|
@admin.register(ProjectExternalBinding)
|
|
class BindingAdmin(admin.ModelAdmin):
|
|
list_display = ["project", "source", "external_name", "external_id"]
|
|
search_fields = ["project__name", "external_name", "external_id"]
|
|
|
|
|
|
class ReadOnlyAdmin(admin.ModelAdmin):
|
|
def has_add_permission(self, request):
|
|
return False
|
|
|
|
def has_change_permission(self, request, obj=None):
|
|
return False
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
return False
|
|
|
|
|
|
admin.site.register(ProjectEvent, ReadOnlyAdmin)
|
|
admin.site.register(DailyAllocation, ReadOnlyAdmin)
|
|
admin.site.register(AllocationRevision, ReadOnlyAdmin)
|
|
admin.site.register(AllocationReminder)
|