Skip to content

Commit

Permalink
Merge branch 'a235605590507661_create_with_documents_metadata'
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Dec 27, 2016
2 parents 75df467 + 99c0de2 commit fcf68cc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openprocurement/contracting/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
contract_create_role = (whitelist(
'id', 'awardID', 'contractID', 'contractNumber', 'title', 'title_en',
'title_ru', 'description', 'description_en', 'description_ru', 'status',
'period', 'value', 'dateSigned', 'documents', 'items', 'suppliers',
'period', 'value', 'dateSigned', 'items', 'suppliers',
'procuringEntity', 'owner', 'tender_token', 'tender_id', 'mode'
))

Expand Down
4 changes: 4 additions & 0 deletions openprocurement/contracting/api/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ def test_create_contract_w_documents(self):
self.assertEqual(response.content_type, 'application/json')
contract = response.json['data']
self.assertEqual(contract['status'], 'active')
for index, doc in enumerate(documents):
self.assertEqual(response.json["data"]['documents'][index]['id'], documents[index]['id'])
self.assertEqual(response.json["data"]['documents'][index]['datePublished'], documents[index]['datePublished'])
self.assertEqual(response.json["data"]['documents'][index]['dateModified'], documents[index]['dateModified'])

self.assertIn('Signature=', response.json["data"]['documents'][-1]["url"])
self.assertIn('KeyID=', response.json["data"]['documents'][-1]["url"])
Expand Down
2 changes: 1 addition & 1 deletion openprocurement/contracting/api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def validate_contract_data(request):
update_logging_context(request, {'contract_id': '__new__'})
data = validate_json_data(request)
data = request.validated['json_data'] = validate_json_data(request)
if data is None:
return
model = request.contract_from_data(data, create=False)
Expand Down
4 changes: 4 additions & 0 deletions openprocurement/contracting/api/views/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def get(self):
validators=(validate_contract_data,))
def post(self):
contract = self.request.validated['contract']
for i in self.request.validated['json_data'].get('documents', []):
doc = type(contract).documents.model_class(i)
doc.__parent__ = contract
contract.documents.append(doc)

# set_ownership(contract, self.request) TODO
self.request.validated['contract'] = contract
Expand Down

0 comments on commit fcf68cc

Please sign in to comment.