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',
|
||||
collections_viewsets.FlawViewSet)
|
||||
router.register(r'adfg-permits', collections_viewsets.ADFGPermitViewSet)
|
||||
router.register(r'datasheet-attachments',
|
||||
collections_viewsets.DatasheetAttachmentViewSet)
|
||||
# Projects
|
||||
router.register(r'projects', projects_viewsets.ProjectViewSet)
|
||||
# Locations
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from rest_framework_json_api import serializers
|
||||
|
||||
from .models import (ADFGPermit, Collection, CollectionMethod, CollectionType,
|
||||
Flaw)
|
||||
Flaw, DatasheetAttachment)
|
||||
|
||||
|
||||
class CollectionSerializer(serializers.ModelSerializer):
|
||||
|
@ -18,6 +18,8 @@ class CollectionSerializer(serializers.ModelSerializer):
|
|||
'flaw': 'ccdb.collections_ccdb.serializers.FlawSerializer',
|
||||
'collection_species':
|
||||
'ccdb.species.serializers.CollectionSpeciesSerializer',
|
||||
'datasheets':
|
||||
'ccdb.collections_ccdb.serializers.DatasheetAttachmentSerializer',
|
||||
}
|
||||
|
||||
class Meta:
|
||||
|
@ -28,8 +30,8 @@ class CollectionSerializer(serializers.ModelSerializer):
|
|||
'collection_end_date', 'collection_end_time',
|
||||
'storage_location', 'specimen_state', 'process_type',
|
||||
'reagent', 'adfg_permit', 'flaw', 'display_name',
|
||||
'collection_species')
|
||||
read_only_fields = ('collection_species',)
|
||||
'collection_species', 'datasheets')
|
||||
read_only_fields = ('collection_species', 'datasheets')
|
||||
|
||||
|
||||
class ADFGPermitSerializer(serializers.ModelSerializer):
|
||||
|
@ -55,3 +57,13 @@ class FlawSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = Flaw
|
||||
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 .models import (ADFGPermit, Collection, CollectionMethod, CollectionType,
|
||||
Flaw)
|
||||
Flaw, DatasheetAttachment)
|
||||
from .serializers import (CollectionSerializer, CollectionMethodSerializer,
|
||||
CollectionTypeSerializer, FlawSerializer,
|
||||
ADFGPermitSerializer)
|
||||
ADFGPermitSerializer, DatasheetAttachmentSerializer)
|
||||
|
||||
|
||||
class CollectionViewSet(viewsets.ModelViewSet):
|
||||
|
@ -34,3 +34,8 @@ class FlawViewSet(viewsets.ModelViewSet):
|
|||
class ADFGPermitViewSet(viewsets.ModelViewSet):
|
||||
queryset = ADFGPermit.objects.all()
|
||||
serializer_class = ADFGPermitSerializer
|
||||
|
||||
|
||||
class DatasheetAttachmentViewSet(viewsets.ModelViewSet):
|
||||
queryset = DatasheetAttachment.objects.all()
|
||||
serializer_class = DatasheetAttachmentSerializer
|
||||
|
|
Loading…
Add table
Reference in a new issue