Skip to content

Commit

Permalink
fixed checks on Munch objects
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaksymiv committed Jun 2, 2016
1 parent 5d8c196 commit eaad05b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions openprocurement/contracting/api/databridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ def get_tender_contracts(self):
contract['tender_id'] = tender['id']
contract['procuringEntity'] = tender['procuringEntity']

if 'items' not in contract:
if not contract.get('items'):
logger.info('Copying contract {} items'.format(contract['id']))
if 'lots' in tender:
if tender.get('lots'):
related_awards = [aw for aw in tender['awards'] if aw['id'] == contract['awardID']]
if related_awards:
award = related_awards[0]
if 'items' in award:
if award.get("items"):
logger.debug('Copying items from related award {}'.format(award['id']))
contract['items'] = award['items']
else:
Expand All @@ -175,7 +175,7 @@ def get_tender_contracts(self):
logger.debug('Copying all tender {} items into contract {}'.format(tender['id'], contract['id']))
contract['items'] = tender['items']

if 'items' not in contract:
if not contract.get('items'):
logger.warn('Contact {} of tender {} does not contain items info'.format(contract['id'], tender['id']))

self.handicap_contracts_queue.put(contract)
Expand Down

0 comments on commit eaad05b

Please sign in to comment.