Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_update_status.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2019 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 rest_framework.parsers import JSONParser | from rest_framework.parsers import JSONParser | ||||
from swh.model.identifiers import ( | from swh.model.identifiers import ( | ||||
persistent_identifier, REVISION, DIRECTORY | persistent_identifier, REVISION, DIRECTORY | ||||
) | ) | ||||
from ..common import SWHPutDepositAPI, SWHPrivateAPIView | from . import SWHPrivateAPIView | ||||
from ..common import SWHPutDepositAPI | |||||
from ...errors import make_error_dict, BAD_REQUEST | from ...errors import make_error_dict, BAD_REQUEST | ||||
from ...models import Deposit, DEPOSIT_STATUS_DETAIL | from ...models import Deposit, DEPOSIT_STATUS_DETAIL | ||||
from ...models import DEPOSIT_STATUS_LOAD_SUCCESS | from ...models import DEPOSIT_STATUS_LOAD_SUCCESS | ||||
class SWHUpdateStatusDeposit(SWHPutDepositAPI, SWHPrivateAPIView): | class SWHUpdateStatusDeposit(SWHPrivateAPIView, SWHPutDepositAPI): | ||||
"""Deposit request class to update the deposit's status. | """Deposit request class to update the deposit's status. | ||||
HTTP verbs supported: PUT | HTTP verbs supported: PUT | ||||
""" | """ | ||||
parser_classes = (JSONParser, ) | parser_classes = (JSONParser, ) | ||||
def additional_checks(self, req, headers, collection_name, | def additional_checks(self, req, headers, collection_name, | ||||
Show All 20 Lines | def additional_checks(self, req, headers, collection_name, | ||||
swh_id = data.get('revision_id') | swh_id = data.get('revision_id') | ||||
if not swh_id: | if not swh_id: | ||||
msg = 'Updating status to %s requires a revision_id key' % ( | msg = 'Updating status to %s requires a revision_id key' % ( | ||||
status, ) | status, ) | ||||
return make_error_dict(BAD_REQUEST, msg) | return make_error_dict(BAD_REQUEST, msg) | ||||
return {} | return {} | ||||
def restrict_access(self, req, deposit=None): | |||||
"""Remove restriction modification to 'partial' deposit. | |||||
Update is possible regardless of the existing status. | |||||
""" | |||||
return None | |||||
def process_put(self, req, headers, collection_name, deposit_id): | def process_put(self, req, headers, collection_name, deposit_id): | ||||
"""Update the deposit's status | """Update the deposit's status | ||||
Returns: | Returns: | ||||
204 No content | 204 No content | ||||
""" | """ | ||||
deposit = Deposit.objects.get(pk=deposit_id) | deposit = Deposit.objects.get(pk=deposit_id) | ||||
Show All 20 Lines |