function.py 1.1 KB
Newer Older
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
1
2
from django.contrib import admin

3
from metagenedb.apps.catalog.models import EggNOGv5, EggNOGFunctionalCategory, Function, KeggOrthology
4
5
6
7
8


@admin.register(KeggOrthology)
class KeggOrthologyAdmin(admin.ModelAdmin):

9
10
    list_display = ('function_id', 'name', 'long_name', 'ec_number')
    search_fields = ('function_id', 'name')
11

12
13
14
15

@admin.register(Function)
class FunctionAdmin(admin.ModelAdmin):

16
    list_display = ('function_id', 'name', 'source')
17
    search_fields = ('function_id',)
18
19


20
21
@admin.register(EggNOGv5)
class EggNOGv5Admin(admin.ModelAdmin):
22

23
    list_display = ('function_id', 'name', 'get_functional_categories')
24
25
    search_fields = ('function_id', 'name')

26
27
    def get_functional_categories(self, obj):
        if obj.functional_categories.all():
28
            return ", ".join([str(f) for f in obj.functional_categories.all()])
29
30
31
        return '-'
    get_functional_categories.short_description = 'Functional categories'

32

33
34
@admin.register(EggNOGFunctionalCategory)
class EggNOGFunctionalCategoryAdmin(admin.ModelAdmin):
35
36
37

    list_display = ('category_id', 'name', 'group')
    search_fields = ('category_id', 'name')