Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 113 additions & 63 deletions cvat/apps/engine/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Copyright (C) 2018-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
Expand All @@ -24,57 +23,70 @@ class JobInline(admin.TabularInline):
model = Job
can_delete = False

autocomplete_fields = ('assignee', )
readonly_fields = ('type', )
autocomplete_fields = ("assignee",)
readonly_fields = ("type",)

def has_add_permission(self, request, obj):
return False


class SegmentInline(admin.TabularInline):
model = Segment
show_change_link = True
readonly_fields = ('start_frame', 'stop_frame')
readonly_fields = ("start_frame", "stop_frame")
can_delete = False

def has_add_permission(self, request, obj):
return False


class AttributeSpecInline(admin.TabularInline):
model = AttributeSpec
extra = 0
max_num = None

readonly_fields = ('mutable', 'input_type', 'default_value', 'values')
readonly_fields = ("mutable", "input_type", "default_value", "values")

def has_add_permission(self, _request, obj):
return False


class LabelInline(admin.TabularInline):
model = Label
show_change_link = True
extra = 0
max_num = None

readonly_fields = ('task', 'project', 'parent', 'type')
readonly_fields = ("task", "project", "parent", "type")


class AssetInline(admin.TabularInline):
model = Asset
extra = 0
max_num = None

list_display = ('__str__', )
readonly_fields = ('filename', 'created_date')
autocomplete_fields = ('owner', )
list_display = ("__str__",)
readonly_fields = ("filename", "created_date")
autocomplete_fields = ("owner",)

def has_add_permission(self, _request, obj):
return False


class DataAdmin(admin.ModelAdmin):
model = Data
fields = ('chunk_size', 'size', 'image_quality', 'start_frame', 'stop_frame', 'frame_filter', 'compressed_chunk_type', 'original_chunk_type')
fields = (
"chunk_size",
"size",
"image_quality",
"start_frame",
"stop_frame",
"frame_filter",
"compressed_chunk_type",
"original_chunk_type",
)
readonly_fields = fields
autocomplete_fields = ('cloud_storage', )
autocomplete_fields = ("cloud_storage",)

def has_change_permission(self, request, obj=None):
return False
Expand All @@ -88,117 +100,155 @@ def has_module_permission(self, request):
def has_add_permission(self, _request):
return False


class StorageAdmin(admin.ModelAdmin):
model = Storage
list_display = ('__str__', 'location', 'cloud_storage')
autocomplete_fields = ('cloud_storage', )
list_display = ("__str__", "location", "cloud_storage")
autocomplete_fields = ("cloud_storage",)

def has_module_permission(self, request):
return False

def has_add_permission(self, _request):
return False


class LabelAdmin(admin.ModelAdmin):
list_display = ('__str__', 'name', 'type', 'task', 'project')
search_fields = ('name', 'task__name', 'project__name')
readonly_fields = ('task', 'project', 'parent', 'type')
list_display = ("__str__", "name", "type", "task", "project")
search_fields = ("name", "task__name", "project__name")
readonly_fields = ("task", "project", "parent", "type")

def has_add_permission(self, _request):
return False

inlines = [
AttributeSpecInline
]
inlines = [AttributeSpecInline]


class SegmentAdmin(admin.ModelAdmin):
list_display = ('__str__', 'task', 'start_frame', 'stop_frame', 'type')
search_fields = ('task__name', )
readonly_fields = ('task', 'start_frame', 'stop_frame', 'type', 'frames')
list_display = ("__str__", "task", "start_frame", "stop_frame", "type")
search_fields = ("task__name",)
readonly_fields = ("task", "start_frame", "stop_frame", "type", "frames")

def has_delete_permission(self, request, obj=None):
return False

def has_module_permission(self, request):
return False

inlines = [
JobInline
]
inlines = [JobInline]


class ProjectAdmin(admin.ModelAdmin):
date_hierarchy = 'created_date'
list_display = ('name', 'organization', 'owner', 'created_date', 'updated_date', 'status')
search_fields = ('name', 'owner__username', 'owner__first_name',
'owner__last_name', 'owner__email', 'assignee__username', 'assignee__first_name',
'assignee__last_name', 'organization__slug')
date_hierarchy = "created_date"
list_display = ("name", "organization", "owner", "created_date", "updated_date", "status")
search_fields = (
"name",
"owner__username",
"owner__first_name",
"owner__last_name",
"owner__email",
"assignee__username",
"assignee__first_name",
"assignee__last_name",
"organization__slug",
)

radio_fields = {
'status': admin.VERTICAL,
"status": admin.VERTICAL,
}

readonly_fields = ('created_date', 'updated_date')
autocomplete_fields = ('owner', 'assignee', 'organization')
raw_id_fields = ('source_storage', 'target_storage')
readonly_fields = ("created_date", "updated_date")
autocomplete_fields = ("owner", "assignee", "organization")
raw_id_fields = ("source_storage", "target_storage")

inlines = [
LabelInline
]
inlines = [LabelInline]

def has_add_permission(self, _request):
return False


class TaskAdmin(admin.ModelAdmin):
date_hierarchy = 'created_date'
list_display = ('name', 'dimension', 'mode', 'organization', 'owner', 'assignee', 'created_date', 'updated_date')
search_fields = ('name', 'mode', 'owner__username', 'owner__first_name',
'owner__last_name', 'owner__email', 'assignee__username', 'assignee__first_name',
'assignee__last_name', 'organization__slug')
date_hierarchy = "created_date"
list_display = (
"name",
"dimension",
"mode",
"organization",
"owner",
"assignee",
"created_date",
"updated_date",
)
search_fields = (
"name",
"mode",
"owner__username",
"owner__first_name",
"owner__last_name",
"owner__email",
"assignee__username",
"assignee__first_name",
"assignee__last_name",
"organization__slug",
)

radio_fields = {
'status': admin.VERTICAL,
"status": admin.VERTICAL,
}

readonly_fields = ('created_date', 'updated_date', 'overlap', 'segment_size', 'data', 'dimension')
autocomplete_fields = ('project', 'owner', 'assignee', 'organization')
raw_id_fields = ('source_storage', 'target_storage', 'data')
readonly_fields = (
"created_date",
"updated_date",
"overlap",
"segment_size",
"data",
"dimension",
)
autocomplete_fields = ("project", "owner", "assignee", "organization")
raw_id_fields = ("source_storage", "target_storage", "data")

inlines = [
SegmentInline,
LabelInline
]
inlines = [SegmentInline, LabelInline]

def has_add_permission(self, request):
return False


class CloudStorageAdmin(admin.ModelAdmin):
date_hierarchy = 'created_date'
list_display = ('__str__', 'resource', 'owner', 'created_date', 'updated_date')
search_fields = ('provider_type', 'display_name', 'resource', 'owner__username', 'owner__first_name',
'owner__last_name', 'owner__email', 'organization__slug')
date_hierarchy = "created_date"
list_display = ("__str__", "resource", "owner", "created_date", "updated_date")
search_fields = (
"provider_type",
"display_name",
"resource",
"owner__username",
"owner__first_name",
"owner__last_name",
"owner__email",
"organization__slug",
)

radio_fields = {
'credentials_type': admin.VERTICAL,
"credentials_type": admin.VERTICAL,
}

readonly_fields = ('created_date', 'updated_date', 'provider_type')
autocomplete_fields = ('owner', 'organization')
readonly_fields = ("created_date", "updated_date", "provider_type")
autocomplete_fields = ("owner", "organization")

def has_add_permission(self, request):
return False


class AnnotationGuideAdmin(admin.ModelAdmin):
list_display = ('__str__', 'task', 'project', 'is_public')
search_fields = ('task__name', 'project__name')
list_display = ("__str__", "task", "project", "is_public")
search_fields = ("task__name", "project__name")

autocomplete_fields = ('task', 'project')
autocomplete_fields = ("task", "project")

def has_add_permission(self, request):
return False

inlines = [
AssetInline
]
inlines = [AssetInline]


admin.site.register(Task, TaskAdmin)
admin.site.register(Segment, SegmentAdmin)
Expand Down
Loading
Loading