Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/content.py
- This file was moved from swh/deposit/api/deposit_content.py.
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from django.http import HttpResponse | from django.http import HttpResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from rest_framework import status | from rest_framework import status | ||||
from ..errors import NOT_FOUND, make_error_response, make_error_response_from_dict | from ..errors import NOT_FOUND, make_error_response, make_error_response_from_dict | ||||
from ..models import DEPOSIT_STATUS_DETAIL, Deposit, DepositRequest | from ..models import DEPOSIT_STATUS_DETAIL, Deposit, DepositRequest | ||||
from .common import APIBase | from .common import APIBase | ||||
class APIContent(APIBase): | class ContentAPI(APIBase): | ||||
"""Deposit request class defining api endpoints for sword deposit. | |||||
What's known as 'Cont-IRI' and 'File-IRI' in the sword specification. | |||||
HTTP verbs supported: GET | |||||
""" | |||||
def get(self, req, collection_name: str, deposit_id: int) -> HttpResponse: | def get(self, req, collection_name: str, deposit_id: int) -> HttpResponse: | ||||
checks = self.checks(req, collection_name, deposit_id) | checks = self.checks(req, collection_name, deposit_id) | ||||
if "error" in checks: | if "error" in checks: | ||||
return make_error_response_from_dict(req, checks["error"]) | return make_error_response_from_dict(req, checks["error"]) | ||||
try: | try: | ||||
deposit = Deposit.objects.get(pk=deposit_id) | deposit = Deposit.objects.get(pk=deposit_id) | ||||
if deposit.collection.name != collection_name: | if deposit.collection.name != collection_name: | ||||
Show All 24 Lines |