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.

84 lines
2.4 KiB

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