Django Library PaTT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin.py 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from django.contrib import admin
  2. from .models import Project, Task, Comment, Search
  3. from simple_history.admin import SimpleHistoryAdmin
  4. class ProjectAdmin(admin.ModelAdmin):
  5. list_display = ('name', 'description', 'id', )
  6. search_fields = ('name', 'description', 'id', )
  7. list_filter = (
  8. ('state', admin.ChoicesFieldListFilter),
  9. ('role_leader', admin.RelatedFieldListFilter),
  10. ('role_member', admin.RelatedFieldListFilter),
  11. )
  12. class TaskAdmin(SimpleHistoryAdmin):
  13. list_display = ('name', 'description', 'id', )
  14. history_list_display = ('name', 'description', 'state', )
  15. search_fields = ('name', 'description', 'id', )
  16. list_filter = (
  17. ('state', admin.ChoicesFieldListFilter),
  18. ('priority', admin.ChoicesFieldListFilter),
  19. ('assigned_user', admin.RelatedFieldListFilter),
  20. ('project', admin.RelatedFieldListFilter),
  21. )
  22. class CommentAdmin(SimpleHistoryAdmin):
  23. list_display = ('task', 'user', 'type', 'comment', )
  24. history_list_display = ('comment', 'type', )
  25. search_fields = ('comment', )
  26. list_filter = (
  27. ('type', admin.ChoicesFieldListFilter),
  28. ('user', admin.RelatedFieldListFilter),
  29. )
  30. class ViewSettingAdmin(admin.ModelAdmin):
  31. list_display = ('profile', 'view', )
  32. search_fields = ('profile', 'view', )
  33. list_filter = (
  34. ('profile', admin.RelatedFieldListFilter),
  35. )
  36. class PattProfileAdmin(admin.ModelAdmin):
  37. list_display = ('user', )
  38. search_fields = ('user', )
  39. list_filter = (
  40. ('user', admin.RelatedFieldListFilter),
  41. )
  42. class SearchAdmin(admin.ModelAdmin):
  43. list_display = ('user', 'name', )
  44. search_fields = ('user', 'name', )
  45. list_filter = (
  46. ('user', admin.RelatedFieldListFilter),
  47. )
  48. admin.site.register(Project, ProjectAdmin)
  49. admin.site.register(Task, TaskAdmin)
  50. admin.site.register(Comment, CommentAdmin)
  51. admin.site.register(Search, SearchAdmin)