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.

90 lines
2.7 KiB

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