Commit b1d5b335 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

update serializer and fix list on frontend

parent e2ada726
Pipeline #53600 failed with stages
in 2 minutes and 32 seconds
......@@ -15,7 +15,7 @@ def create_sources(apps, schema_editor):
{
'name': 'IGC-9.9M',
'url': 'https://db.cngb.org/microbiome/genecatalog/genecatalog_human/',
'doi': '10.1038/s41467-020-14677-3'
'doi': '10.1038/nbt.2942'
},
]
for item in items_to_create:
......
......@@ -3,11 +3,12 @@ import traceback
from rest_framework import serializers
from rest_framework.utils import model_meta
from metagenedb.apps.catalog.models import Function, Gene, GeneFunction, Taxonomy
from metagenedb.apps.catalog.models import Function, Gene, GeneFunction, Source, Taxonomy
from .asymetricslugrelatedfield import AsymetricSlugRelatedField
from .bulk_list import BulkListSerializer
from .function import FunctionSerializer
from .source import SourceSerializer
from .taxonomy import SimpleTaxonomySerializer
......@@ -65,6 +66,12 @@ class GeneSerializer(serializers.ModelSerializer):
slug_field='tax_id',
required=False,
)
source = AsymetricSlugRelatedField.from_serializer(
SourceSerializer,
queryset=Source.objects.all(),
slug_field='name',
required=False,
)
class Meta:
model = Gene
......
from rest_framework import serializers
from metagenedb.apps.catalog.models import Source
class SourceSerializer(serializers.ModelSerializer):
class Meta:
model = Source
fields = (
'name', 'url', 'doi'
)
......@@ -337,7 +337,14 @@
</v-btn>
</template>
</td>
<td class="text-xs">{{ props.item.source }}</td>
<td class="text-xs">
{{ props.item.source }}
<v-btn :href="props.item.source_url" icon flat small target="_blank" class="secondary--text mt-1 ml-0" v-if="props.item.source">
<v-icon small>
open_in_new
</v-icon>
</v-btn>
</td>
</template>
</v-data-table>
</v-list>
......
......@@ -233,6 +233,10 @@ export default {
item.tax_url = ncbiTaxUrl + item.taxonomy.tax_id;
item.taxonomy = `${item.taxonomy.name} (${item.taxonomy.rank})`;
}
if (item.source) {
item.source_url = item.source.url;
item.source = item.source.name;
}
if (item.functions) {
const { functions } = item;
item.keggs = [];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment