ENH: Collection attachments (#36)
This commit is contained in:
parent
2a7b11720e
commit
a908b06b99
3 changed files with 24 additions and 5 deletions
|
@ -23,6 +23,8 @@ router.register(r'collection-types',
|
||||||
router.register(r'collection-flaws',
|
router.register(r'collection-flaws',
|
||||||
collections_viewsets.FlawViewSet)
|
collections_viewsets.FlawViewSet)
|
||||||
router.register(r'adfg-permits', collections_viewsets.ADFGPermitViewSet)
|
router.register(r'adfg-permits', collections_viewsets.ADFGPermitViewSet)
|
||||||
|
router.register(r'datasheet-attachments',
|
||||||
|
collections_viewsets.DatasheetAttachmentViewSet)
|
||||||
# Projects
|
# Projects
|
||||||
router.register(r'projects', projects_viewsets.ProjectViewSet)
|
router.register(r'projects', projects_viewsets.ProjectViewSet)
|
||||||
# Locations
|
# Locations
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from rest_framework_json_api import serializers
|
from rest_framework_json_api import serializers
|
||||||
|
|
||||||
from .models import (ADFGPermit, Collection, CollectionMethod, CollectionType,
|
from .models import (ADFGPermit, Collection, CollectionMethod, CollectionType,
|
||||||
Flaw)
|
Flaw, DatasheetAttachment)
|
||||||
|
|
||||||
|
|
||||||
class CollectionSerializer(serializers.ModelSerializer):
|
class CollectionSerializer(serializers.ModelSerializer):
|
||||||
|
@ -18,6 +18,8 @@ class CollectionSerializer(serializers.ModelSerializer):
|
||||||
'flaw': 'ccdb.collections_ccdb.serializers.FlawSerializer',
|
'flaw': 'ccdb.collections_ccdb.serializers.FlawSerializer',
|
||||||
'collection_species':
|
'collection_species':
|
||||||
'ccdb.species.serializers.CollectionSpeciesSerializer',
|
'ccdb.species.serializers.CollectionSpeciesSerializer',
|
||||||
|
'datasheets':
|
||||||
|
'ccdb.collections_ccdb.serializers.DatasheetAttachmentSerializer',
|
||||||
}
|
}
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -28,8 +30,8 @@ class CollectionSerializer(serializers.ModelSerializer):
|
||||||
'collection_end_date', 'collection_end_time',
|
'collection_end_date', 'collection_end_time',
|
||||||
'storage_location', 'specimen_state', 'process_type',
|
'storage_location', 'specimen_state', 'process_type',
|
||||||
'reagent', 'adfg_permit', 'flaw', 'display_name',
|
'reagent', 'adfg_permit', 'flaw', 'display_name',
|
||||||
'collection_species')
|
'collection_species', 'datasheets')
|
||||||
read_only_fields = ('collection_species',)
|
read_only_fields = ('collection_species', 'datasheets')
|
||||||
|
|
||||||
|
|
||||||
class ADFGPermitSerializer(serializers.ModelSerializer):
|
class ADFGPermitSerializer(serializers.ModelSerializer):
|
||||||
|
@ -55,3 +57,13 @@ class FlawSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Flaw
|
model = Flaw
|
||||||
fields = ('id', 'name', 'description', 'sort_order')
|
fields = ('id', 'name', 'description', 'sort_order')
|
||||||
|
|
||||||
|
|
||||||
|
class DatasheetAttachmentSerializer(serializers.ModelSerializer):
|
||||||
|
included_serializers = {
|
||||||
|
'collection': 'ccdb.collections_ccdb.serializers.CollectionSerializer',
|
||||||
|
}
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DatasheetAttachment
|
||||||
|
fields = ('id', 'collection', 'datasheet')
|
||||||
|
|
|
@ -3,10 +3,10 @@ from django_filters import rest_framework as filters
|
||||||
|
|
||||||
from .filters import CollectionFilter
|
from .filters import CollectionFilter
|
||||||
from .models import (ADFGPermit, Collection, CollectionMethod, CollectionType,
|
from .models import (ADFGPermit, Collection, CollectionMethod, CollectionType,
|
||||||
Flaw)
|
Flaw, DatasheetAttachment)
|
||||||
from .serializers import (CollectionSerializer, CollectionMethodSerializer,
|
from .serializers import (CollectionSerializer, CollectionMethodSerializer,
|
||||||
CollectionTypeSerializer, FlawSerializer,
|
CollectionTypeSerializer, FlawSerializer,
|
||||||
ADFGPermitSerializer)
|
ADFGPermitSerializer, DatasheetAttachmentSerializer)
|
||||||
|
|
||||||
|
|
||||||
class CollectionViewSet(viewsets.ModelViewSet):
|
class CollectionViewSet(viewsets.ModelViewSet):
|
||||||
|
@ -34,3 +34,8 @@ class FlawViewSet(viewsets.ModelViewSet):
|
||||||
class ADFGPermitViewSet(viewsets.ModelViewSet):
|
class ADFGPermitViewSet(viewsets.ModelViewSet):
|
||||||
queryset = ADFGPermit.objects.all()
|
queryset = ADFGPermit.objects.all()
|
||||||
serializer_class = ADFGPermitSerializer
|
serializer_class = ADFGPermitSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class DatasheetAttachmentViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = DatasheetAttachment.objects.all()
|
||||||
|
serializer_class = DatasheetAttachmentSerializer
|
||||||
|
|
Loading…
Add table
Reference in a new issue