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.

81 lines
2.6 KiB

6 years ago
3 years ago
3 years ago
  1. from django.contrib import admin
  2. from .models import (Comment, Document, DocumentAnnotation, Label, Project,
  3. Role, RoleMapping, Seq2seqAnnotation, Seq2seqProject,
  4. SequenceAnnotation, SequenceLabelingProject, Tag,
  5. TextClassificationProject)
  6. class LabelAdmin(admin.ModelAdmin):
  7. list_display = ('text', 'project', 'text_color', 'background_color')
  8. ordering = ('project',)
  9. search_fields = ('text',)
  10. class DocumentAdmin(admin.ModelAdmin):
  11. list_display = ('text', 'project', 'meta')
  12. ordering = ('project',)
  13. search_fields = ('text',)
  14. class ProjectAdmin(admin.ModelAdmin):
  15. list_display = ('name', 'description', 'project_type', 'randomize_document_order', 'collaborative_annotation')
  16. ordering = ('project_type',)
  17. search_fields = ('name',)
  18. class SequenceAnnotationAdmin(admin.ModelAdmin):
  19. list_display = ('document', 'label', 'start_offset', 'user')
  20. ordering = ('document',)
  21. search_fields = ('document__text',)
  22. class DocumentAnnotationAdmin(admin.ModelAdmin):
  23. list_display = ('document', 'label', 'user')
  24. ordering = ('document',)
  25. search_fields = ('document__text',)
  26. class Seq2seqAnnotationAdmin(admin.ModelAdmin):
  27. list_display = ('document', 'text', 'user')
  28. ordering = ('document',)
  29. search_fields = ('document__text',)
  30. class RoleAdmin(admin.ModelAdmin):
  31. list_display = ('name', 'description')
  32. ordering = ('name',)
  33. search_fields = ('name',)
  34. class RoleMappingAdmin(admin.ModelAdmin):
  35. list_display = ('user', 'role', 'project', )
  36. ordering = ('user',)
  37. search_fields = ('user__username',)
  38. class TagAdmin(admin.ModelAdmin):
  39. list_display = ('project', 'text', )
  40. ordering = ('project', 'text', )
  41. search_fields = ('text',)
  42. class CommentAdmin(admin.ModelAdmin):
  43. list_display = ('user', 'document', 'text', 'created_at', )
  44. ordering = ('user', 'created_at', )
  45. search_fields = ('user',)
  46. admin.site.register(DocumentAnnotation, DocumentAnnotationAdmin)
  47. admin.site.register(SequenceAnnotation, SequenceAnnotationAdmin)
  48. admin.site.register(Seq2seqAnnotation, Seq2seqAnnotationAdmin)
  49. admin.site.register(Label, LabelAdmin)
  50. admin.site.register(Document, DocumentAdmin)
  51. admin.site.register(Project, ProjectAdmin)
  52. admin.site.register(TextClassificationProject, ProjectAdmin)
  53. admin.site.register(SequenceLabelingProject, ProjectAdmin)
  54. admin.site.register(Seq2seqProject, ProjectAdmin)
  55. admin.site.register(Role, RoleAdmin)
  56. admin.site.register(RoleMapping, RoleMappingAdmin)
  57. admin.site.register(Comment, CommentAdmin)
  58. admin.site.register(Tag, TagAdmin)