Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9345472
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/swh/deposit/api/private/deposit_update_status.py b/swh/deposit/api/private/deposit_update_status.py
index 6c09c890..cbb8ccce 100644
--- a/swh/deposit/api/private/deposit_update_status.py
+++ b/swh/deposit/api/private/deposit_update_status.py
@@ -1,74 +1,74 @@
# Copyright (C) 2017-2018 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
from rest_framework.parsers import JSONParser
from swh.model.identifiers import persistent_identifier, REVISION
from ..common import SWHPutDepositAPI, SWHPrivateAPIView
from ...errors import make_error_dict, BAD_REQUEST
from ...models import Deposit, DEPOSIT_STATUS_DETAIL
from ...models import DEPOSIT_STATUS_LOAD_SUCCESS
class SWHUpdateStatusDeposit(SWHPutDepositAPI, SWHPrivateAPIView):
"""Deposit request class to update the deposit's status.
HTTP verbs supported: PUT
"""
parser_classes = (JSONParser, )
def additional_checks(self, req, headers, collection_name,
deposit_id=None):
"""Enrich existing checks to the default ones.
New checks:
- Ensure the status is provided
- Ensure it exists
"""
data = req.data
status = data.get('status')
if not status:
msg = 'The status key is mandatory with possible values %s' % list(
DEPOSIT_STATUS_DETAIL.keys())
return make_error_dict(BAD_REQUEST, msg)
if status not in DEPOSIT_STATUS_DETAIL:
msg = 'Possible status in %s' % list(DEPOSIT_STATUS_DETAIL.keys())
return make_error_dict(BAD_REQUEST, msg)
if status == DEPOSIT_STATUS_LOAD_SUCCESS:
swh_id = data.get('revision_id')
if not swh_id:
msg = 'Updating status to %s requires a revision_id key' % (
status, )
return make_error_dict(BAD_REQUEST, msg)
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):
"""Update the deposit's status
Returns:
204 No content
"""
deposit = Deposit.objects.get(pk=deposit_id)
deposit.status = req.data['status'] # checks already done before
swh_id = req.data.get('revision_id')
if swh_id:
- deposit.swh_id = persistent_identifier(REVISION, swh_id)
+ deposit.swh_id = persistent_identifier(REVISION, {'id': swh_id})
deposit.save()
return {}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jul 4, 3:22 PM (5 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3253564
Attached To
rDDEP Push deposit
Event Timeline
Log In to Comment