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.

100 lines
2.8 KiB

3 years ago
3 years ago
6 years ago
3 years ago
3 years ago
3 years ago
  1. from django.contrib import admin
  2. from .models import (AutoLabelingConfig, Category, Comment, DocType, Example,
  3. Project, Role, RoleMapping, Seq2seqProject,
  4. SequenceLabelingProject, Span, SpanType, Tag,
  5. TextClassificationProject, TextLabel)
  6. class LabelAdmin(admin.ModelAdmin):
  7. list_display = ('text', 'project', 'text_color', 'background_color')
  8. ordering = ('project',)
  9. search_fields = ('text',)
  10. class DocTypeAdmin(LabelAdmin):
  11. pass
  12. class SpanTypeAdmin(LabelAdmin):
  13. pass
  14. class ExampleAdmin(admin.ModelAdmin):
  15. list_display = ('text', 'project', 'meta')
  16. ordering = ('project',)
  17. search_fields = ('text',)
  18. class ProjectAdmin(admin.ModelAdmin):
  19. list_display = ('name', 'description', 'project_type', 'random_order', 'collaborative_annotation')
  20. ordering = ('project_type',)
  21. search_fields = ('name',)
  22. class SpanAdmin(admin.ModelAdmin):
  23. list_display = ('example', 'label', 'start_offset', 'user')
  24. ordering = ('example',)
  25. class CategoryAdmin(admin.ModelAdmin):
  26. list_display = ('example', 'label', 'user')
  27. ordering = ('example',)
  28. class TextLabelAdmin(admin.ModelAdmin):
  29. list_display = ('example', 'text', 'user')
  30. ordering = ('example',)
  31. class RoleAdmin(admin.ModelAdmin):
  32. list_display = ('name', 'description')
  33. ordering = ('name',)
  34. search_fields = ('name',)
  35. class RoleMappingAdmin(admin.ModelAdmin):
  36. list_display = ('user', 'role', 'project', )
  37. ordering = ('user',)
  38. search_fields = ('user__username',)
  39. class TagAdmin(admin.ModelAdmin):
  40. list_display = ('project', 'text', )
  41. ordering = ('project', 'text', )
  42. search_fields = ('text',)
  43. class CommentAdmin(admin.ModelAdmin):
  44. list_display = ('user', 'example', 'text', 'created_at', )
  45. ordering = ('user', 'created_at', )
  46. search_fields = ('user',)
  47. class AutoLabelingConfigAdmin(admin.ModelAdmin):
  48. list_display = ('project', 'model_name', 'model_attrs',)
  49. ordering = ('project',)
  50. def get_readonly_fields(self, request, obj=None):
  51. if obj:
  52. return ["model_name"]
  53. else:
  54. return []
  55. admin.site.register(AutoLabelingConfig, AutoLabelingConfigAdmin)
  56. admin.site.register(Category, CategoryAdmin)
  57. admin.site.register(Span, SpanAdmin)
  58. admin.site.register(TextLabel, TextLabelAdmin)
  59. # admin.site.register(Label, LabelAdmin)
  60. admin.site.register(DocType, DocTypeAdmin)
  61. admin.site.register(SpanType, SpanTypeAdmin)
  62. admin.site.register(Example, ExampleAdmin)
  63. admin.site.register(Project, ProjectAdmin)
  64. admin.site.register(TextClassificationProject, ProjectAdmin)
  65. admin.site.register(SequenceLabelingProject, ProjectAdmin)
  66. admin.site.register(Seq2seqProject, ProjectAdmin)
  67. admin.site.register(Role, RoleAdmin)
  68. admin.site.register(RoleMapping, RoleMappingAdmin)
  69. admin.site.register(Comment, CommentAdmin)
  70. admin.site.register(Tag, TagAdmin)