Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
f0fb2d72
Commit
f0fb2d72
authored
Dec 10, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
update model for m2m eggnog - functional cat
parent
e7c74843
Pipeline
#19698
passed with stages
in 2 minutes and 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/apps/catalog/admin/function.py
View file @
f0fb2d72
...
...
@@ -20,9 +20,15 @@ class FunctionAdmin(admin.ModelAdmin):
@
admin
.
register
(
EggNog
)
class
EggNogAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'function_id'
,
'name'
,
'functional_categor
y
'
)
list_display
=
(
'function_id'
,
'name'
,
'
get_
functional_categor
ies
'
)
search_fields
=
(
'function_id'
,
'name'
)
def
get_functional_categories
(
self
,
obj
):
if
obj
.
functional_categories
.
all
():
return
","
.
join
([
str
(
f
)
for
f
in
obj
.
functional_categories
.
all
()])
return
'-'
get_functional_categories
.
short_description
=
'Functional categories'
@
admin
.
register
(
EggNogFunctionalCategory
)
class
EggNogFunctionalCategoryAdmin
(
admin
.
ModelAdmin
):
...
...
backend/metagenedb/apps/catalog/migrations/0015_m2m_func_cat_eggnog.py
0 → 100644
View file @
f0fb2d72
# Generated by Django 3.0 on 2019-12-10 14:28
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalog'
,
'0014_eggnog_name_length'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'eggnog'
,
options
=
{
'verbose_name'
:
'EggNOG'
,
'verbose_name_plural'
:
'EggNOGs'
},
),
migrations
.
AlterModelOptions
(
name
=
'eggnogfunctionalcategory'
,
options
=
{
'verbose_name'
:
'EggNOG functional category'
,
'verbose_name_plural'
:
'EggNOG functional categories'
},
),
migrations
.
AlterModelOptions
(
name
=
'keggorthology'
,
options
=
{
'verbose_name'
:
'KEGG orthology'
,
'verbose_name_plural'
:
'KEGG orthologies'
},
),
migrations
.
RemoveField
(
model_name
=
'eggnog'
,
name
=
'functional_category'
,
),
migrations
.
AddField
(
model_name
=
'eggnog'
,
name
=
'functional_categories'
,
field
=
models
.
ManyToManyField
(
to
=
'catalog.EggNogFunctionalCategory'
),
),
]
backend/metagenedb/apps/catalog/models/function.py
View file @
f0fb2d72
...
...
@@ -32,23 +32,8 @@ class KeggOrthology(Function):
super
(
KeggOrthology
,
self
).
__init__
(
source
=
self
.
SOURCE
,
*
args
,
**
kwargs
)
class
Meta
:
verbose_name_plural
=
"Kegg orthologies"
class
EggNog
(
Function
):
SOURCE
=
'eggnog'
functional_category
=
models
.
ForeignKey
(
'EggNogFunctionalCategory'
,
related_name
=
'eggnogs'
,
on_delete
=
models
.
SET_NULL
,
null
=
True
,
blank
=
True
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
EggNog
,
self
).
__init__
(
source
=
self
.
SOURCE
,
*
args
,
**
kwargs
)
class
Meta
:
verbose_name_plural
=
"EggNog"
verbose_name
=
"KEGG orthology"
verbose_name_plural
=
"KEGG orthologies"
class
EggNogFunctionalCategory
(
models
.
Model
):
...
...
@@ -67,4 +52,18 @@ class EggNogFunctionalCategory(models.Model):
return
f
"
{
self
.
category_id
}
(
{
self
.
name
}
)"
class
Meta
:
verbose_name_plural
=
"EggNog Functional categories"
verbose_name
=
"EggNOG functional category"
verbose_name_plural
=
"EggNOG functional categories"
class
EggNog
(
Function
):
SOURCE
=
'eggnog'
functional_categories
=
models
.
ManyToManyField
(
EggNogFunctionalCategory
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
EggNog
,
self
).
__init__
(
source
=
self
.
SOURCE
,
*
args
,
**
kwargs
)
class
Meta
:
verbose_name
=
"EggNOG"
verbose_name_plural
=
"EggNOGs"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment