-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working api to list all datasets and all of their reverse foriegn key…
… relation ships
- Loading branch information
Showing
8 changed files
with
95 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
from rest_framework import generics | ||
from rest_framework import permissions | ||
from rest_framework import viewsets | ||
|
||
from dataset.models import Dataset | ||
from dataset.serializers import DatasetSerializer | ||
|
||
class DatasetAPIList(generics.ListCreateAPIView): | ||
queryset = Dataset.objects.all() | ||
serializer_class = DatasetSerializer | ||
|
||
class DatasetAPIDetail(generics.RetrieveUpdateDestroyAPIView): | ||
class DatasetAPIList(generics.ListAPIView): | ||
queryset = Dataset.objects.all() | ||
serializer_class = DatasetSerializer |
19 changes: 19 additions & 0 deletions
19
open_fmri/apps/dataset/migrations/0025_auto_20151118_2256.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dataset', '0024_dataset_curated'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='publicationpubmedlink', | ||
name='dataset', | ||
field=models.ForeignKey(related_name='pubmed_link', to='dataset.Dataset'), | ||
), | ||
] |
19 changes: 19 additions & 0 deletions
19
open_fmri/apps/dataset/migrations/0026_auto_20151118_2308.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dataset', '0025_auto_20151118_2256'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='publicationpubmedlink', | ||
name='dataset', | ||
field=models.ForeignKey(to='dataset.Dataset'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from rest_framework import serializers | ||
|
||
from dataset.models import Dataset, Investigator, PublicationDocument, \ | ||
PublicationPubMedLink, Revision, Task | ||
|
||
class InvestigatorSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Investigator | ||
fields = ['investigator'] | ||
|
||
class PublicationDocumentSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = PublicationDocument | ||
fields = ['document'] | ||
|
||
class PublicationPubMedLinkSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = PublicationPubMedLink | ||
fields = ['title', 'url'] | ||
|
||
class RevisionSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Revision | ||
fields = ['revision_number', 'notes', 'aws_link_title', 'aws_link_url'] | ||
|
||
class TaskSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Task | ||
fields = ['cogat_id', 'number'] | ||
|
||
class DatasetSerializer(serializers.ModelSerializer): | ||
|
||
investigator_set = InvestigatorSerializer(read_only=True, many=True) | ||
publicationdocument_set = serializers.StringRelatedField() | ||
publicationpubmedlink_set = PublicationPubMedLinkSerializer(read_only=True, | ||
many=True) | ||
task_set = TaskSerializer(read_only=True, many=True) | ||
revision_set = RevisionSerializer(read_only=True, many=True) | ||
class Meta: | ||
model = Dataset | ||
fields = [ | ||
'workflow_stage', 'status', 'project_name', 'summary', | ||
'sample_size', 'scanner_type', 'accession_number', | ||
'acknowledgements', 'license_title', 'license_url', 'curated', | ||
'publicationdocument_set', 'publicationpubmedlink_set', 'task_set', | ||
'revision_set', 'investigator_set' | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters