Skip to content

Commit

Permalink
Imports via API now are only allowed for projects of type PROJECT (
Browse files Browse the repository at this point in the history
  • Loading branch information
stolpeo committed Dec 3, 2021
1 parent 392b842 commit c1b9355
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions HISTORY.rst
Expand Up @@ -20,6 +20,7 @@ End-User Summary
- Allowing project owners and delegates to import cases via API (#207).
- Fix for broken link-out into MutationTaster (#240).
- Fixing SODAR Core template inconsistency (#150).
- Imports via API now are only allowed for projects of type ``PROJECT`` (#237).

Full Change List
================
Expand All @@ -39,6 +40,7 @@ Full Change List
- Allowing project owners and delegates to import cases via API (#207).
- Fix for broken link-out into MutationTaster (#240).
- Fixing SODAR Core template inconsistency (#150).
- Imports via API now are only allowed for projects of type ``PROJECT`` (#237).

-------
v0.23.9
Expand Down
17 changes: 16 additions & 1 deletion importer/views_api.py
Expand Up @@ -5,7 +5,7 @@
from bgjobs.models import BackgroundJob
from django.contrib.auth import get_user_model
from django.db import transaction
from projectroles.views import ProjectPermissionMixin
from projectroles.constants import get_sodar_constants
from projectroles.views_api import SODARAPIBaseProjectMixin, SODARAPIGenericProjectMixin
from rest_framework.generics import (
ListCreateAPIView,
Expand All @@ -30,10 +30,14 @@
#: The User model to use.
User = get_user_model()

#: Get SODAR contants.
SODAR_CONSTANTS = get_sodar_constants()


class CaseImportInfoListCreateView(SODARAPIGenericProjectMixin, ListCreateAPIView):
"""DRF list-create API view the ``CaseImportInfo`` model."""

project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]
serializer_class = CaseImportInfoSerializer

def get_queryset(self):
Expand Down Expand Up @@ -63,6 +67,7 @@ class CaseImportInfoRetrieveUpdateDestroyView(
lookup_field = "sodar_uuid"
lookup_url_kwarg = "caseimportinfo"
serializer_class = CaseImportInfoSerializer
project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]

def perform_update(self, serializer):
old_state = self.get_object().state
Expand Down Expand Up @@ -127,6 +132,8 @@ class VariantSetImportBaseMixin(SODARAPIBaseProjectMixin, RelatedMixin):
related_lookup_field = "case_import_info"
related_lookup_url_kwarg = "caseimportinfo"

project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]


class VariantSetImportInfoListCreateView(VariantSetImportBaseMixin, ListCreateAPIView):
"""DRF list-create API view the ``VariantSetImportInfo`` model."""
Expand Down Expand Up @@ -163,6 +170,8 @@ class BamQcFileBaseMixin(SODARAPIBaseProjectMixin, RelatedMixin):
related_lookup_field = "case_import_info"
related_lookup_url_kwarg = "caseimportinfo"

project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]


class BamQcFileListCreateView(BamQcFileBaseMixin, ListCreateAPIView):
"""DRF list-create API view the ``BamQcFile`` model."""
Expand Down Expand Up @@ -197,6 +206,8 @@ class GenotypeFileBaseMixin(SODARAPIBaseProjectMixin, RelatedMixin):
related_lookup_field = "variant_set_import_info"
related_lookup_url_kwarg = "variantsetimportinfo"

project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]


class GenotypeFileListCreateView(GenotypeFileBaseMixin, ListCreateAPIView):
"""DRF list-create API view the ``GenotypeFile`` model."""
Expand Down Expand Up @@ -231,6 +242,8 @@ class EffectsFileBaseMixin(SODARAPIBaseProjectMixin, RelatedMixin):
related_lookup_field = "variant_set_import_info"
related_lookup_url_kwarg = "variantsetimportinfo"

project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]


class EffectsFileListCreateView(EffectsFileBaseMixin, ListCreateAPIView):
"""DRF list-create API view the ``EffectsFile`` model."""
Expand Down Expand Up @@ -265,6 +278,8 @@ class DatabaseInfoFileBaseMixin(SODARAPIBaseProjectMixin, RelatedMixin):
related_lookup_field = "variant_set_import_info"
related_lookup_url_kwarg = "variantsetimportinfo"

project_type = SODAR_CONSTANTS["PROJECT_TYPE_PROJECT"]


class DatabaseInfoFileListCreateView(DatabaseInfoFileBaseMixin, ListCreateAPIView):
"""DRF list-create API view the ``DatabaseInfoFile`` model."""
Expand Down

0 comments on commit c1b9355

Please sign in to comment.