admin.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. from django.contrib import admin
  2. from models import Project, Task, Risk, Issue, Status
  3. # Register your models here.
  4. class TaskAdmin(admin.ModelAdmin):
  5. list_display = (
  6. 'title',
  7. 'project',
  8. 'status',
  9. 'start',
  10. 'end',
  11. )
  12. ordering = ['start']
  13. list_filter = ['start', 'status']
  14. class TaskInline(admin.TabularInline):
  15. model = Task
  16. extra=0
  17. class RiskAdmin(admin.ModelAdmin):
  18. list_display = [
  19. 'name',
  20. 'project',
  21. 'impact',
  22. 'status',
  23. ]
  24. ordering = [
  25. 'project',
  26. '-impact',
  27. ]
  28. list_filter = [
  29. 'project',
  30. 'status',
  31. 'impact',
  32. ]
  33. class RiskInline(admin.StackedInline):
  34. model = Risk
  35. extra=0
  36. class IssueAdmin(admin.ModelAdmin):
  37. list_display = (
  38. 'name',
  39. 'project',
  40. 'severity',
  41. 'status',
  42. )
  43. ordering = ['project', '-severity']
  44. list_filter = ['project', 'status']
  45. class IssueInline(admin.StackedInline):
  46. model = Issue
  47. extra=0
  48. class StatusAdmin(admin.ModelAdmin):
  49. list_display = (
  50. 'date',
  51. 'project',
  52. 'cost',
  53. 'time',
  54. 'quality',
  55. )
  56. ordering = ['project','date']
  57. list_filter = ['project', 'cost', 'time', 'quality']
  58. class StatusInline(admin.TabularInline):
  59. model = Status
  60. extra=0
  61. class ProjectAdmin(admin.ModelAdmin):
  62. list_display = (
  63. 'name',
  64. )
  65. inlines = [
  66. StatusInline,
  67. RiskInline,
  68. IssueInline,
  69. TaskInline,
  70. ]
  71. admin.site.register(Task, TaskAdmin)
  72. admin.site.register(Risk, RiskAdmin)
  73. admin.site.register(Issue, IssueAdmin)
  74. admin.site.register(Status, StatusAdmin)
  75. admin.site.register(Project, ProjectAdmin)