browser audio processing phase 1
This commit is contained in:
@@ -10,7 +10,7 @@ from django.urls import path, reverse
|
||||
from django.utils.html import format_html
|
||||
from django.utils.translation import gettext as _, gettext_lazy, ngettext
|
||||
|
||||
from .models import ClassificationRule, Event, PendingEvent, Sensor
|
||||
from .models import BrowserProcessingSettings, ClassificationRule, Event, PendingEvent, Sensor
|
||||
from . import views as classifier_views
|
||||
|
||||
|
||||
@@ -21,6 +21,33 @@ class ClassificationRuleAdmin(admin.ModelAdmin):
|
||||
search_fields = ("value",)
|
||||
|
||||
|
||||
@admin.register(BrowserProcessingSettings)
|
||||
class BrowserProcessingSettingsAdmin(admin.ModelAdmin):
|
||||
list_display = ("beta_status",)
|
||||
readonly_fields = ("beta_status",)
|
||||
fieldsets = (
|
||||
(gettext_lazy("Browser-side media processing (Beta)"), {
|
||||
"fields": ("beta_status", "browser_processing_beta_enabled"),
|
||||
"description": gettext_lazy(
|
||||
"Enables experimental client-side video audio extraction and YAMNet pre-classification. "
|
||||
"Browser compatibility may vary. Disabling this restores the normal server-side submission flow."
|
||||
),
|
||||
}),
|
||||
)
|
||||
|
||||
@admin.display(description=gettext_lazy("Beta status"))
|
||||
def beta_status(self, obj):
|
||||
if obj and obj.browser_processing_beta_enabled:
|
||||
return format_html('<strong style="color:#166534">{}</strong>', _("Enabled"))
|
||||
return format_html('<strong style="color:#991b1b">{}</strong>', _("Disabled — normal submission"))
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return super().has_add_permission(request) and not BrowserProcessingSettings.objects.exists()
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
|
||||
class ClassificationAdmin(admin.ModelAdmin):
|
||||
list_display = ("original_filename", "source_type", "sensor", "occurrences", "location", "visually_confirmed", "primary_label", "primary_score", "duration", "created_at")
|
||||
list_filter = ("source_type", "visually_confirmed", "created_at")
|
||||
|
||||
Reference in New Issue
Block a user