Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a323834626545561_fix_document_ur…
Browse files Browse the repository at this point in the history
…l_on_put'
  • Loading branch information
vmaksymiv committed May 3, 2017
2 parents 0b43472 + 0fe64ba commit b2d154f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 5 additions & 7 deletions src/openprocurement/api/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,11 @@ def update_doc_url(document):
for i in results:
changed = False
doc = i.doc
if doc.get('procurementMethodType', '') in ['aboveThresholdEU', "competitiveDialogueUA", "competitiveDialogueEU", "competitiveDialogueEU.stage2", "competitiveDialogueUA.stage2"]:
for bid in doc.get('bids', []):
for document_type in ['documents', 'financialDocuments', 'eligibilityDocuments', 'qualificationDocuments']:
for document in bid.get(document_type, []):
if document.get('confidentiality', 'public') == 'buyerOnly':
if update_doc_url(document):
changed = True
for bid in doc.get('bids', []):
for document_type in ['documents', 'financialDocuments', 'eligibilityDocuments', 'qualificationDocuments']:
for document in bid.get(document_type, []):
if update_doc_url(document):
changed = True
if changed:
docs.append(doc)
if len(docs) >= 2 ** 7:
Expand Down
7 changes: 3 additions & 4 deletions src/openprocurement/api/tests/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ def test_migrate_from23to24(self):
u.tenderID = "UA-X"
u.store(self.db)
tender_raw = self.db.get(u.id)
tender_raw['procurementMethodType'] = 'aboveThresholdEU' # dirty eu simulation
bid = {"id": "1b4da15470e84c4d948a5d1660d29776"}
bid["documents"] = [
{
Expand All @@ -783,10 +782,9 @@ def test_migrate_from23to24(self):
"dateModified": "2016-06-01T00:00:00+03:00",
"format": "text/plain",
"language": "uk",
"confidentiality": "buyerOnly" # documents for which url is not rewrited to ds url
},
{
# non-ds url. should NOT be rewrited by migrator
# non-ds url. should be fixed (correct id in url) by migrator
"id": "f3e5470b76f84c66a89fd52ed871f645",
"title": "name.txt",
"documentOf": "tender",
Expand All @@ -807,6 +805,7 @@ def test_migrate_from23to24(self):
}
]

# dirty eligibility documents container simulation
bid["eligibilityDocuments"] = [
{
# non-ds url. should be fixed (correct id in url) by migrator
Expand All @@ -832,10 +831,10 @@ def test_migrate_from23to24(self):

# url should be corrected
self.assertIn("/tenders/{}/bids/1b4da15470e84c4d948a5d1660d29776/documents/1801ca2749bd40b0944e58adc3e09c46?download=a65ef5c688884931aed1a472620d3a00".format(u.id), migrated_bid['documents'][0]['url'])
self.assertIn("/tenders/{}/bids/1b4da15470e84c4d948a5d1660d29776/documents/f3e5470b76f84c66a89fd52ed871f645?download=d48723d7b4014599ac8d94fb0ac958b4".format(u.id), migrated_bid['documents'][1]['url'])
self.assertIn("/tenders/{}/bids/1b4da15470e84c4d948a5d1660d29776/eligibility_documents/73e728784f924518b07f16e34750df1b?download=5443af5e910f46debe412fc36e69f1ad".format(u.id), migrated_bid['eligibilityDocuments'][0]['url'])

# url remained the same as before migration
self.assertIn("/tenders/{}/bids/1b4da15470e84c4d948a5d1660d29776/documents/512bd84155b145b99e0ac80894fe2b8f?download=d48723d7b4014599ac8d94fb0ac958b4".format(u.id), migrated_bid['documents'][1]['url'])
self.assertIn("http://localhost.ds/get/b893bf5d2fb44a26bd6896178afe5953?KeyID=i_am_ds_url_lalalalala", migrated_bid['documents'][2]['url'])


Expand Down

0 comments on commit b2d154f

Please sign in to comment.