Browse Source

Add admin interface for AutoLabelingConfigs. Solves #1423

Thanks to @uklft for the idea.
pull/1438/head
Roland Szabo 3 years ago
parent
commit
d4cb96f4fd
2 changed files with 15 additions and 2 deletions
  1. 15
      backend/api/admin.py
  2. 2
      backend/api/models.py

15
backend/api/admin.py

@ -2,7 +2,8 @@ from django.contrib import admin
from .models import (Category, Comment, Example, Label, Project, Role,
RoleMapping, Seq2seqProject, SequenceLabelingProject,
Span, Tag, TextClassificationProject, TextLabel)
Span, Tag, TextClassificationProject, TextLabel,
AutoLabelingConfig)
class LabelAdmin(admin.ModelAdmin):
@ -62,6 +63,18 @@ class CommentAdmin(admin.ModelAdmin):
search_fields = ('user',)
class AutoLabelingConfigAdmin(admin.ModelAdmin):
list_display = ('project', 'model_name', 'model_attrs',)
ordering = ('project',)
def get_readonly_fields(self, request, obj=None):
if obj:
return ["model_name"]
else:
return []
admin.site.register(AutoLabelingConfig, AutoLabelingConfigAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Span, SpanAdmin)
admin.site.register(TextLabel, TextLabelAdmin)

2
backend/api/models.py

@ -339,7 +339,7 @@ class AutoLabelingConfig(models.Model):
model_name = models.CharField(max_length=100)
model_attrs = models.JSONField(default=dict)
template = models.TextField(default='')
label_mapping = models.JSONField(default=dict)
label_mapping = models.JSONField(default=dict, blank=True)
project = models.ForeignKey(
to=Project,
on_delete=models.CASCADE,

Loading…
Cancel
Save