Skip to content

Commit

Permalink
Merge pull request #11 from gorserg/bridge_update
Browse files Browse the repository at this point in the history
Rewrite tender stage 2 if it stats in rewrite_statuses
  • Loading branch information
vmaksymiv committed Jul 8, 2016
2 parents 8364b16 + 44a450d commit 271ef0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions openprocurement/tender/competitivedialogue/databridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
DATABRIDGE_CD_PATCHED_STAGE2_ID, DATABRIDGE_PATCH_NEW_TENDER_STATUS, DATABRIDGE_SUCCESSFUL_PATCH_NEW_TENDER_STATUS,
DATABRIDGE_UNSUCCESSFUL_PATCH_NEW_TENDER_STATUS, DATABRIDGE_PATCH_DIALOG_STATUS,
DATABRIDGE_UNSUCCESSFUL_PATCH_DIALOG_STATUS, DATABRIDGE_SUCCESSFUL_PATCH_DIALOG_STATUS, DATABRIDGE_ONLY_PATCH,
DATABRIDGE_TENDER_STAGE2_NOT_EXIST)
DATABRIDGE_TENDER_STAGE2_NOT_EXIST, DATABRIDGE_CREATE_NEW_STAGE2)


dialog_work = set() # local storage for current competitive dialogue in main queue
Expand Down Expand Up @@ -109,6 +109,10 @@ class CompetitiveDialogueDataBridge(object):
""" Competitive Dialogue Data Bridge """
copy_name_fields = ('title_ru', 'mode', 'procurementMethodDetails', 'title_en', 'description', 'description_en',
'description_ru', 'title', 'minimalStep', 'value', 'procuringEntity')
rewrite_statuses = ['draft']
allowed_statuses = ['active.tendering', 'active.pre-qualification', 'active.pre-qualification.stand-still',
'active.auction', 'active.qualification', 'active.awarded', 'complete', 'cancelled',
'unsuccessful', STAGE2_STATUS]

def __init__(self, config):
super(CompetitiveDialogueDataBridge, self).__init__()
Expand Down Expand Up @@ -233,14 +237,18 @@ def get_competitive_dialogue_data(self):
extra=journal_context({"MESSAGE_ID": DATABRIDGE_TENDER_STAGE2_NOT_EXIST},
{"TENDER_ID": tender['id']}))
else:
if tender_stage2.get('status') == 'draft.stage2':
if tender_stage2.get('status') in self.allowed_statuses:
logger.info('For dialog {0} tender stage 2 already exists, need only patch'.format(tender['id']),
extra=journal_context({"MESSAGE_ID": DATABRIDGE_ONLY_PATCH},
{"TENDER_ID": tender['id']}))
patch_data = {"id": tender['id'],
"status": "complete"}
self.dialog_set_complete_queue.put(patch_data)
continue
elif tender_stage2.get('status') in self.rewrite_statuses:
logger.info('Tender stage 2 id={0} has bad status need to create new '.format(tender['id']),
extra=journal_context({"MESSAGE_ID": DATABRIDGE_CREATE_NEW_STAGE2},
{"TENDER_ID": tender['id']}))

logger.info('Copy competitive dialogue data, id={} '.format(tender['id']),
extra=journal_context({"MESSAGE_ID": DATABRIDGE_COPY_TENDER_ITEMS},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
DATABRIDGE_SUCCESSFUL_PATCH_DIALOG_STATUS = "cd_bridge_successful_patch_dialog_status"
DATABRIDGE_ONLY_PATCH = 'cd_bridge_need_patch'
DATABRIDGE_TENDER_STAGE2_NOT_EXIST = 'cd_bridge_tender_stage2_not_exist'
DATABRIDGE_CREATE_NEW_STAGE2 = 'cd_bridge_create_new_tender_stage2'

0 comments on commit 271ef0e

Please sign in to comment.