1
0

admin.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from django.contrib import admin
  2. from django.utils.safestring import mark_safe
  3. from tickets.models import Attachment, Comment, TicketList, Ticket, TicketArchive
  4. class TicketListAdmin(admin.ModelAdmin):
  5. list_filter = ("group",)
  6. class TicketAdmin(admin.ModelAdmin):
  7. list_display = ("title", "ticket_list", "status", "created_by", "assigned_to", "created_at", "updated_at", "due_date", "priority")
  8. list_filter =("ticket_list", "status", "created_by", "assigned_to", "created_at", "updated_at")
  9. ordering = ("priority",)
  10. search_fields = ("title", "note")
  11. class TicketArchiveAdmin(admin.ModelAdmin):
  12. list_display = ("title", "ticket_list", "status", "created_by", "assigned_to", "created_at", "updated_at", "due_date")
  13. list_filter = ("ticket_list", "status", "created_by", "assigned_to", "created_at", "updated_at")
  14. search_fields = ("title", "note")
  15. readonly_fields = ("title", "ticket_list", "ticket_type", "status", "created_at", "updated_at", "due_date", "created_by", "assigned_to", "display_note")
  16. def display_note(self, obj):
  17. return mark_safe(obj.note)
  18. class CommentAdmin(admin.ModelAdmin):
  19. list_display = ("author", "date", "snippet")
  20. class AttachmentAdmin(admin.ModelAdmin):
  21. list_display = ("ticket", "added_by", "timestamp", "file")
  22. autocomplete_fields = ["added_by", "ticket"]
  23. admin.site.register(TicketList, TicketListAdmin)
  24. admin.site.register(Ticket, TicketAdmin)
  25. admin.site.register(TicketArchive, TicketArchiveAdmin)
  26. admin.site.register(Comment, CommentAdmin)
  27. admin.site.register(Attachment, AttachmentAdmin)