Skip to content

Commit

Permalink
Fixed patching documents
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Feb 11, 2015
1 parent 69dd414 commit 5296a31
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/openprocurement/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ def get_filename(data):


def upload_file(request):
first_document = None
first_document = request.validated['documents'][0] if 'documents' in request.validated and request.validated['documents'] else None
if request.content_type == 'multipart/form-data':
data = request.validated['file']
filename = get_filename(data)
content_type = data.type
in_file = data.file
else:
first_document = request.validated['documents'][0]
filename = first_document.title
content_type = request.content_type
in_file = request.body_file
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/views/award_complaint_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def put(self):
LOGGER.info('Updated tender award complaint document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_award_complaint_document_put'})
return {'data': document.serialize("view")}

@view(renderer='json', validators=(validate_patch_document_data,), permission='review_complaint')
@view(content_type="application/json", renderer='json', validators=(validate_patch_document_data,), permission='review_complaint')
def patch(self):
"""Tender Award Complaint Document Update"""
if self.request.validated['tender_status'] not in ['active.qualification', 'active.awarded']:
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/views/award_contract_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def put(self):
LOGGER.info('Updated tender award contract document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_award_contract_document_put'})
return {'data': document.serialize("view")}

@view(renderer='json', validators=(validate_patch_document_data,), permission='edit_tender')
@view(content_type="application/json", renderer='json', validators=(validate_patch_document_data,), permission='edit_tender')
def patch(self):
"""Tender Award Contract Document Update"""
if self.request.validated['tender_status'] not in ['active.awarded', 'complete']:
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/views/award_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def put(self):
LOGGER.info('Updated tender award document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_award_document_put'})
return {'data': document.serialize("view")}

@view(renderer='json', validators=(validate_patch_document_data,), permission='edit_tender')
@view(content_type="application/json", renderer='json', validators=(validate_patch_document_data,), permission='edit_tender')
def patch(self):
"""Tender Award Document Update"""
if self.request.validated['tender_status'] != 'active.qualification':
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/views/bid_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def put(self):
LOGGER.info('Updated tender bid document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_bid_document_put'})
return {'data': document.serialize("view")}

@view(renderer='json', validators=(validate_patch_document_data,), permission='edit_bid')
@view(content_type="application/json", renderer='json', validators=(validate_patch_document_data,), permission='edit_bid')
def patch(self):
"""Tender Bid Document Update"""
if self.request.validated['tender_status'] not in ['active.tendering', 'active.auction', 'active.qualification']:
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/views/complaint_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def put(self):
LOGGER.info('Updated tender complaint document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_complaint_document_put'})
return {'data': document.serialize("view")}

@view(renderer='json', validators=(validate_patch_document_data,), permission='review_complaint')
@view(content_type="application/json", renderer='json', validators=(validate_patch_document_data,), permission='review_complaint')
def patch(self):
"""Tender Complaint Document Update"""
if self.request.validated['tender_status'] not in ['active.enquiries', 'active.tendering', 'active.auction', 'active.qualification', 'active.awarded']:
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/views/tender_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def put(self):
LOGGER.info('Updated tender document {}'.format(self.request.context.id), extra={'MESSAGE_ID': 'tender_document_put'})
return {'data': document.serialize("view")}

@view(renderer='json', permission='upload_tender_documents', validators=(validate_patch_document_data,))
@view(content_type="application/json", renderer='json', permission='upload_tender_documents', validators=(validate_patch_document_data,))
def patch(self):
"""Tender Document Update"""
if self.request.authenticated_role != 'auction' and self.request.validated['tender_status'] != 'active.enquiries' or \
Expand Down

0 comments on commit 5296a31

Please sign in to comment.