Commit 1b99773d authored by Mike Hoang's avatar Mike Hoang
Browse files

fix(isCurrentTenant property): renamed isCurrentTenant -> bidderPriorityPresence

parent ec916775
import importlib import importlib
import os import os
CURRENT_VERSION = 38 CURRENT_VERSION = 39
def get_m_files(): def get_m_files():
......
def apply(data):
if 'legitimatePropertyLease-priorityEnglish' in data.get('sellingMethod'):
if bids := data.get('bids'):
for bid in bids.values():
is_current_tenant = bid.pop('isCurrentTenant', None)
if isinstance(is_current_tenant, bool):
bid['bidderPriorityPresence'] = is_current_tenant
return data
...@@ -1330,7 +1330,7 @@ schemas: ...@@ -1330,7 +1330,7 @@ schemas:
readOnly: true readOnly: true
type: number type: number
format: float format: float
isCurrentTenant: bidderPriorityPresence:
readOnly: true readOnly: true
type: boolean type: boolean
required: required:
......
...@@ -674,7 +674,7 @@ schemas: ...@@ -674,7 +674,7 @@ schemas:
- $ref: '#/components/schemas/legitimatePropertyLease-english.Bid' - $ref: '#/components/schemas/legitimatePropertyLease-english.Bid'
- type: object - type: object
properties: properties:
isCurrentTenant: bidderPriorityPresence:
type: boolean type: boolean
default: false default: false
readOnly: true readOnly: true
......
...@@ -278,7 +278,7 @@ class PriorityBid(base.Bid): ...@@ -278,7 +278,7 @@ class PriorityBid(base.Bid):
import_roles = { import_roles = {
'owner': ( 'owner': (
role.ImportRoleChain() role.ImportRoleChain()
+ blacklist('classification', 'isCurrentTenant') + blacklist('classification', 'bidderPriorityPresence')
+ role.ImportStatusRole({'active_tendering'}, + role.ImportStatusRole({'active_tendering'},
whitelist( whitelist(
'bidders', 'status', 'value', 'unit', 'quantity', 'documents', 'bidders', 'status', 'value', 'unit', 'quantity', 'documents',
......
...@@ -305,14 +305,14 @@ class PriorityTendering(Tendering): ...@@ -305,14 +305,14 @@ class PriorityTendering(Tendering):
return False return False
def checking_current_tenant_exist(self): def checking_current_tenant_exist(self):
if len([x for x in self.procedure.bids if x.isCurrentTenant is True and x.status == 'active']) > 1: if len([x for x in self.procedure.bids if x.bidderPriorityPresence is True and x.status == 'active']) > 1:
raise errors.DataError({'bidders': {'identifier': {'id': 'Bid for current tenant is already registered'}}}) raise errors.DataError({'bidders': {'identifier': {'id': 'Bid for current tenant is already registered'}}})
@bidder @bidder
def update_bid_status(self, bid_id, status, context): def update_bid_status(self, bid_id, status, context):
super().update_bid_status(bid_id, status, context) super().update_bid_status(bid_id, status, context)
bid = self.procedure.bids[bid_id] bid = self.procedure.bids[bid_id]
bid.isCurrentTenant = self.check_bid_is_from_current_tenant(bid) bid.bidderPriorityPresence = self.check_bid_is_from_current_tenant(bid)
self.checking_current_tenant_exist() self.checking_current_tenant_exist()
......
...@@ -103,8 +103,8 @@ class _CurrentTenantDeterminationMixin: ...@@ -103,8 +103,8 @@ class _CurrentTenantDeterminationMixin:
return return
tenant_count = 0 tenant_count = 0
for bid in value: for bid in value:
bid.isCurrentTenant = self.check_bid_is_from_current_tenant(bid) bid.bidderPriorityPresence = self.check_bid_is_from_current_tenant(bid)
if bid.isCurrentTenant and bid.status == 'active': if bid.bidderPriorityPresence and bid.status == 'active':
tenant_count += 1 tenant_count += 1
if tenant_count > 1: if tenant_count > 1:
raise DataError({'bidders': {'identifier': {'id': 'Bid for current tenant is already registered'}}}) raise DataError({'bidders': {'identifier': {'id': 'Bid for current tenant is already registered'}}})
......
...@@ -41,11 +41,11 @@ class TestProcedureQualification: ...@@ -41,11 +41,11 @@ class TestProcedureQualification:
assert test_procedure.status == 'active_qualification' assert test_procedure.status == 'active_qualification'
bid_1 = test_procedure.bids[0] bid_1 = test_procedure.bids[0]
assert bid_1.isCurrentTenant is True assert bid_1.bidderPriorityPresence is True
assert bid_1.bidders[0].identifier.id == test_procedure.relatedOrganizations.currentTenant.identifier.id assert bid_1.bidders[0].identifier.id == test_procedure.relatedOrganizations.currentTenant.identifier.id
bid_2 = test_procedure.bids[-1] bid_2 = test_procedure.bids[-1]
assert bid_2.isCurrentTenant is False assert bid_2.bidderPriorityPresence is False
assert bid_2.bidders[0].identifier.id != test_procedure.relatedOrganizations.currentTenant.identifier.id assert bid_2.bidders[0].identifier.id != test_procedure.relatedOrganizations.currentTenant.identifier.id
with pytest.raises(errors.DataError, match='^{"bidders": {"identifier": ' with pytest.raises(errors.DataError, match='^{"bidders": {"identifier": '
......
...@@ -26,61 +26,61 @@ class TestAuctionState: ...@@ -26,61 +26,61 @@ class TestAuctionState:
@pytest.mark.parametrize("bids", [ @pytest.mark.parametrize("bids", [
pytest.param([ pytest.param([
{ {
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'amount': 100 'amount': 100
}, },
{ {
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'amount': 100 'amount': 100
}, },
], id='tenant_first'), ], id='tenant_first'),
pytest.param([ pytest.param([
{ {
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'amount': 100 'amount': 100
}, },
{ {
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'amount': 100 'amount': 100
}, },
], id='tenant_second'), ], id='tenant_second'),
pytest.param([ pytest.param([
{ {
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'amount': 90 'amount': 90
}, },
{ {
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'amount': 100 'amount': 100
}, },
], id='tenant_first with amount 90'), ], id='tenant_first with amount 90'),
pytest.param([ pytest.param([
{ {
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'amount': 100 'amount': 100
}, },
{ {
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'amount': 90 'amount': 90
}, },
], id='tenant_second with amount 90'), ], id='tenant_second with amount 90'),
pytest.param([ pytest.param([
{ {
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'amount': 110 'amount': 110
}, },
{ {
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'amount': 100 'amount': 100
}, },
], id='tenant_first with amount 110'), ], id='tenant_first with amount 110'),
pytest.param([ pytest.param([
{ {
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'amount': 100 'amount': 100
}, },
{ {
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'amount': 110 'amount': 110
}, },
], id='tenant_second with amount 110'), ], id='tenant_second with amount 110'),
...@@ -92,7 +92,7 @@ class TestAuctionState: ...@@ -92,7 +92,7 @@ class TestAuctionState:
for idx, val in enumerate(bids): for idx, val in enumerate(bids):
bids[idx]['bidders'] = bid_data['bidders'] bids[idx]['bidders'] = bid_data['bidders']
bids[idx]["dateModified"] = datetime.now().isoformat() bids[idx]["dateModified"] = datetime.now().isoformat()
if val['isCurrentTenant']: if val['bidderPriorityPresence']:
bids[idx]['bidders'][0]['identifier']['id'] = tenant_id bids[idx]['bidders'][0]['identifier']['id'] = tenant_id
else: else:
bids[idx]['bidders'][0]['identifier']['id'] = not_tenant_id bids[idx]['bidders'][0]['identifier']['id'] = not_tenant_id
...@@ -114,7 +114,7 @@ class TestAuctionState: ...@@ -114,7 +114,7 @@ class TestAuctionState:
assert procedure.status == "active_auction" assert procedure.status == "active_auction"
for ix, procedure_bid in enumerate(procedure.bids): for ix, procedure_bid in enumerate(procedure.bids):
assert procedure_bid.isCurrentTenant == bids[ix]['isCurrentTenant'] assert procedure_bid.bidderPriorityPresence == bids[ix]['bidderPriorityPresence']
procedure_bids = deepcopy(procedure.bids) procedure_bids = deepcopy(procedure.bids)
auction_data_bids = { auction_data_bids = {
...@@ -134,9 +134,9 @@ class TestAuctionState: ...@@ -134,9 +134,9 @@ class TestAuctionState:
assert procedure.status == 'active_qualification' assert procedure.status == 'active_qualification'
assert len(procedure.awards) == 2 assert len(procedure.awards) == 2
keys = list(auction_data_bids.keys()) keys = list(auction_data_bids.keys())
if bids[0]['isCurrentTenant']: if bids[0]['bidderPriorityPresence']:
assert procedure_bids[procedure.awards[1].bidId].isCurrentTenant assert procedure_bids[procedure.awards[1].bidId].bidderPriorityPresence
else: else:
assert procedure_bids[procedure.awards[0].bidId].isCurrentTenant assert procedure_bids[procedure.awards[0].bidId].bidderPriorityPresence
assert procedure.awards[0].bidId == keys[0] assert procedure.awards[0].bidId == keys[0]
assert procedure.awards[1].bidId == keys[1] assert procedure.awards[1].bidId == keys[1]
...@@ -12,13 +12,13 @@ class TestProcedureQualification: ...@@ -12,13 +12,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY 'date': TODAY
}, },
{ {
'id': 2, 'id': 2,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
} }
), ),
...@@ -28,13 +28,13 @@ class TestProcedureQualification: ...@@ -28,13 +28,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY 'date': TODAY
}, },
{ {
'id': 2, 'id': 2,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
} }
), ),
...@@ -44,13 +44,13 @@ class TestProcedureQualification: ...@@ -44,13 +44,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
}, },
{ {
'id': 2, 'id': 2,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
} }
), ),
...@@ -60,13 +60,13 @@ class TestProcedureQualification: ...@@ -60,13 +60,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
}, },
{ {
'id': 2, 'id': 2,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
} }
), ),
...@@ -76,13 +76,13 @@ class TestProcedureQualification: ...@@ -76,13 +76,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
}, },
{ {
'id': 2, 'id': 2,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
} }
), ),
...@@ -92,13 +92,13 @@ class TestProcedureQualification: ...@@ -92,13 +92,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
}, },
{ {
'id': 2, 'id': 2,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
} }
), ),
...@@ -108,13 +108,13 @@ class TestProcedureQualification: ...@@ -108,13 +108,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': True, 'bidderPriorityPresence': True,
'date': TODAY 'date': TODAY
}, },
{ {
'id': 2, 'id': 2,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
} }
), ),
...@@ -124,13 +124,13 @@ class TestProcedureQualification: ...@@ -124,13 +124,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
}, },
{ {
'id': 2, 'id': 2,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
} }
), ),
...@@ -140,13 +140,13 @@ class TestProcedureQualification: ...@@ -140,13 +140,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
}, },
{ {
'id': 2, 'id': 2,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
} }
), ),
...@@ -156,13 +156,13 @@ class TestProcedureQualification: ...@@ -156,13 +156,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
}, },
{ {
'id': 2, 'id': 2,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
} }
), ),
...@@ -172,13 +172,13 @@ class TestProcedureQualification: ...@@ -172,13 +172,13 @@ class TestProcedureQualification:
{ {
'id': 1, 'id': 1,
'amount': 1000, 'amount': 1000,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY + timedelta(minutes=1) 'date': TODAY + timedelta(minutes=1)
}, },
{ {
'id': 2, 'id': 2,
'amount': 1001, 'amount': 1001,
'isCurrentTenant': False, 'bidderPriorityPresence': False,
'date': TODAY 'date': TODAY
} }
),