Browse Source

Merge pull request #1438 from rolisz/autolabeladmin

Add admin interface for AutoLabelingConfigs. Solves #1423
pull/1520/head
Hiroki Nakayama 3 years ago
committed by GitHub
parent
commit
8b4b8e7635
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions
  1. 19
      backend/api/admin.py
  2. 2
      backend/api/models.py

19
backend/api/admin.py

@ -1,8 +1,9 @@
from django.contrib import admin
from .models import (Category, Comment, Example, Label, Project, Role,
RoleMapping, Seq2seqProject, SequenceLabelingProject,
Span, Tag, TextClassificationProject, TextLabel)
from .models import (AutoLabelingConfig, Category, Comment, Example, Label,
Project, Role, RoleMapping, Seq2seqProject,
SequenceLabelingProject, Span, Tag,
TextClassificationProject, TextLabel)
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