Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/__init__.py
# Copyright (C) 2017-2019 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 swh.deposit import utils | from swh.deposit import utils | ||||
from ...config import METADATA_TYPE, SWHDefaultConfig | from ...config import METADATA_TYPE, SWHDefaultConfig | ||||
from ...models import DepositRequest, Deposit | from ...models import DepositRequest, Deposit | ||||
from rest_framework.permissions import AllowAny | from rest_framework.permissions import AllowAny | ||||
from swh.deposit.api.common import SWHAPIView | from swh.deposit.api.common import AuthenticatedAPIView | ||||
from swh.deposit.errors import make_error_dict, NOT_FOUND | from swh.deposit.errors import make_error_dict, NOT_FOUND | ||||
class DepositReadMixin: | class DepositReadMixin: | ||||
"""Deposit Read mixin | """Deposit Read mixin | ||||
""" | """ | ||||
Show All 31 Lines | def _metadata_get(self, deposit): | ||||
""" | """ | ||||
metadata = ( | metadata = ( | ||||
m.metadata | m.metadata | ||||
for m in self._deposit_requests(deposit, request_type=METADATA_TYPE) | for m in self._deposit_requests(deposit, request_type=METADATA_TYPE) | ||||
) | ) | ||||
return utils.merge(*metadata) | return utils.merge(*metadata) | ||||
class SWHPrivateAPIView(SWHDefaultConfig, SWHAPIView): | class SWHPrivateAPIView(SWHDefaultConfig, AuthenticatedAPIView): | ||||
"""Mixin intended as private api (so no authentication) based API view | """Mixin intended as private api (so no authentication) based API view | ||||
(for the private ones). | (for the private ones). | ||||
""" | """ | ||||
authentication_classes = () | authentication_classes = () | ||||
permission_classes = (AllowAny,) | permission_classes = (AllowAny,) | ||||
Show All 40 Lines |