Skip to content

Commit

Permalink
Merge pull request #96 from ProzorroUKR/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
smithumble authored Aug 1, 2024
2 parents ebd83c6 + 2338e9c commit f6fad32
Show file tree
Hide file tree
Showing 159 changed files with 2,742 additions and 1,369 deletions.
333 changes: 113 additions & 220 deletions README.md

Large diffs are not rendered by default.

36 changes: 22 additions & 14 deletions procedure_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import json
import logging
from copy import deepcopy, copy
from base64 import b64encode
from copy import copy, deepcopy
from datetime import timedelta

from procedure_tools.utils.date import get_utcnow, parse_date_header
Expand All @@ -17,22 +17,25 @@

from procedure_tools.utils import adapters
from procedure_tools.utils.handlers import (
response_handler,
client_init_response_handler,
response_handler,
)
from procedure_tools.version import __version__

API_PATH_PREFIX_DEFAULT = "/api/0/"


class BaseApiClient(object):
name = "api"

SPORE_PATH = "spore"

HEADERS_DEFAULT = {
"User-Agent": "procedure_tools/{}".format(__version__),
}

def __init__(self, host, session=None, debug=False, **kwargs):
logging.info(f"Initializing {self.name} client\n")
self.host = host
self.kwargs = kwargs
self.debug = debug
Expand Down Expand Up @@ -93,7 +96,10 @@ def request(self, method, path, **kwargs):
if self.debug:
self.log_request(request_kwargs.get("json", None))
self.log_response(response.text)
response_handler(response, **handlers)
if response.status_code == 409:
response = self.request(method, path, **kwargs)
else:
response_handler(response, **handlers)
return response

def get(self, path, **kwargs):
Expand All @@ -110,6 +116,8 @@ def patch(self, path, json=None, **kwargs):


class BaseCDBClient(BaseApiClient):
name = "cdb"

SPORE_PATH = "spore"

def __init__(
Expand All @@ -124,7 +132,7 @@ def __init__(
self.path_prefix = path_prefix
self.set_kwargs(auth_token)
spore_url = self.get_url(self.get_api_path(self.SPORE_PATH))
# GET request to retrieve SERVER_ID cookie and server time
# GET request to retrieve cookies and server time
response = self.session.get(spore_url)
client_datetime = get_utcnow()
try:
Expand All @@ -147,6 +155,8 @@ def get_api_path(self, path, acc_token=None):


class TendersApiClient(BaseCDBClient):
name = "tenders"

TENDERS_COLLECTION_PATH = "tenders"
TENDERS_PATH = "tenders/{}"
TENDERS_DOCUMENTS_COLLECTION_PATH = "tenders/{}/documents"
Expand All @@ -160,7 +170,6 @@ class TendersApiClient(BaseCDBClient):
AWARDS_PATH = "tenders/{}/awards/{}"
CONTRACTS_COLLECTION_PATH = "tenders/{}/contracts"
CONTRACTS_PATH = "tenders/{}/contracts/{}"
CONTRACT_UNIT_VALUE_PATH = "tenders/{}/contracts/{}/items/{}/unit/value"
QUALIFICATIONS_COLLECTION_PATH = "tenders/{}/qualifications"
QUALIFICATIONS_PATH = "tenders/{}/qualifications/{}"
AGREEMENTS_COLLECTION_PATH = "tenders/{}/agreements"
Expand Down Expand Up @@ -373,15 +382,6 @@ def patch_contract(self, tender_id, contract_id, acc_token, json, **kwargs):
path = self.get_api_path(awards_path, acc_token=acc_token)
return self.patch(path, json, **kwargs)

def patch_contract_unit_value(
self, tender_id, contract_id, item_id, acc_token, json, **kwargs
):
awards_path = self.CONTRACT_UNIT_VALUE_PATH.format(
tender_id, contract_id, item_id, acc_token
)
path = self.get_api_path(awards_path, acc_token=acc_token)
return self.patch(path, json, **kwargs)

def get_agreements(self, tender_id, **kwargs):
agreements_path = self.AGREEMENTS_COLLECTION_PATH.format(tender_id)
path = self.get_api_path(agreements_path)
Expand Down Expand Up @@ -426,6 +426,8 @@ def patch_credentials(self, tender_id, acc_token, json, **kwargs):


class AgreementsApiClient(BaseCDBClient):
name = "agreements"

AGREEMENTS_PATH = "agreements/{}"

def get_agreement(self, agreement_id, **kwargs):
Expand All @@ -435,6 +437,8 @@ def get_agreement(self, agreement_id, **kwargs):


class ContractsApiClient(BaseCDBClient):
name = "contracts"

CONTRACTS_PATH = "contracts/{}"
BUYERS_SIGNER_INFO_PATH = "contracts/{}/buyer/signer_info"
SUPPLIERS_SIGNER_INFO_PATH = "contracts/{}/suppliers/signer_info"
Expand Down Expand Up @@ -469,6 +473,8 @@ def patch_credentials(self, contract_id, acc_token, json, **kwargs):


class PlansApiClient(BaseCDBClient):
name = "plans"

PLANS_COLLECTION_PATH = "plans"
PLANS_PATH = "plans/{}"
TENDERS_COLLECTION_PATH = "plans/{}/tenders"
Expand All @@ -495,6 +501,8 @@ def post_tender(self, plan_id, json, **kwargs):


class DsApiClient(BaseApiClient):
name = "ds"

UPLOAD_PATH = "upload"

def __init__(
Expand Down
55 changes: 55 additions & 0 deletions procedure_tools/data/aboveThreshold.features/bid_create_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"data": {
"parameters": [
{
"code": "73763ce0c908466ead064f8a2de02a9f",
"value": 0.05
},
{
"code": "48cfd91612c04125ab406374d7cc8d93",
"value": 0.01
}
],
"lotValues": [
{
"relatedLot": "dd22c9c085f64e019f943999b5b41fe5",
"subcontractingDetails": "ДКП «Орфей», Україна",
"value": {
"amount": 500
}
},
{
"relatedLot": "9d4fc4783ebb4a99b10cc9a2f7d7552f",
"subcontractingDetails": "ДКП «Орфей», Україна",
"value": {
"amount": 500
}
}
],
"selfQualified": true,
"status": "draft",
"tenderers": [
{
"address": {
"countryName": "Україна",
"locality": "м. Київ",
"postalCode": "21100",
"region": "м. Київ",
"streetAddress": "вул. Польова, 33"
},
"contactPoint": {
"email": "[email protected]",
"name": "Микола Олексюк",
"telephone": "+380000000000"
},
"identifier": {
"id": "00137200",
"scheme": "UA-EDR",
"uri": "http://factory.example.com"
},
"name": "ДКП «Орфей»",
"scale": "micro"
}
]
}
}
46 changes: 43 additions & 3 deletions procedure_tools/data/aboveThreshold.features/contract_patch_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,49 @@
"valueAddedTaxIncluded": false
},
"period": {
"startDate": "{{ helpers.now() }}",
"endDate": "{{ helpers.now(days=365, acceleration=acceleration) }}"
"startDate": "{{ from_now_iso() }}",
"endDate": "{{ from_now_iso(days=365) }}"
},
"contractNumber": 1
"contractNumber": 1,
"items": [
{
"id": "{{ contracts[0]['items'][0].id }}",
"additionalClassifications": [
{
"description": "{{ contracts[0]['items'][0].additionalClassifications[0].description }}",
"id": "{{ contracts[0]['items'][0].additionalClassifications[0].id }}",
"scheme": "{{ contracts[0]['items'][0].additionalClassifications[0].scheme }}"
}
],
"classification": {
"description": "{{ contracts[0]['items'][0].classification.description }}",
"id": "{{ contracts[0]['items'][0].classification.id }}",
"scheme": "{{ contracts[0]['items'][0].classification.scheme }}"
},
"deliveryAddress": {
"countryName": "{{ contracts[0]['items'][0].deliveryAddress.countryName }}",
"locality": "{{ contracts[0]['items'][0].deliveryAddress.locality }}",
"postalCode": "{{ contracts[0]['items'][0].deliveryAddress.postalCode }}",
"region": "{{ contracts[0]['items'][0].deliveryAddress.region }}",
"streetAddress": "{{ contracts[0]['items'][0].deliveryAddress.streetAddress }}"
},
"deliveryDate": {
"startDate": "{{ contracts[0]['items'][0].deliveryDate.startDate }}",
"endDate": "{{ contracts[0]['items'][0].deliveryDate.endDate }}"
},
"description": "{{ contracts[0]['items'][0].description }}",
"description_en": "{{ contracts[0]['items'][0].description_en }}",
"relatedLot": "{{ contracts[0]['items'][0].relatedLot }}",
"quantity": 1,
"unit": {
"code": "{{ contracts[0]['items'][0].unit.code }}",
"name": "{{ contracts[0]['items'][0].unit.name }}",
"value": {
"amount": 10.0,
"valueAddedTaxIncluded": false
}
}
}
]
}
}
46 changes: 43 additions & 3 deletions procedure_tools/data/aboveThreshold.features/contract_patch_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,49 @@
"valueAddedTaxIncluded": false
},
"period": {
"startDate": "{{ helpers.now() }}",
"endDate": "{{ helpers.now(days=365, acceleration=acceleration) }}"
"startDate": "{{ from_now_iso() }}",
"endDate": "{{ from_now_iso(days=365) }}"
},
"contractNumber": 2
"contractNumber": 2,
"items": [
{
"id": "{{ contracts[1]['items'][0].id }}",
"additionalClassifications": [
{
"description": "{{ contracts[1]['items'][0].additionalClassifications[0].description }}",
"id": "{{ contracts[1]['items'][0].additionalClassifications[0].id }}",
"scheme": "{{ contracts[1]['items'][0].additionalClassifications[0].scheme }}"
}
],
"classification": {
"description": "{{ contracts[1]['items'][0].classification.description }}",
"id": "{{ contracts[1]['items'][0].classification.id }}",
"scheme": "{{ contracts[1]['items'][0].classification.scheme }}"
},
"deliveryAddress": {
"countryName": "{{ contracts[1]['items'][0].deliveryAddress.countryName }}",
"locality": "{{ contracts[1]['items'][0].deliveryAddress.locality }}",
"postalCode": "{{ contracts[1]['items'][0].deliveryAddress.postalCode }}",
"region": "{{ contracts[1]['items'][0].deliveryAddress.region }}",
"streetAddress": "{{ contracts[1]['items'][0].deliveryAddress.streetAddress }}"
},
"deliveryDate": {
"startDate": "{{ contracts[1]['items'][0].deliveryDate.startDate }}",
"endDate": "{{ contracts[1]['items'][0].deliveryDate.endDate }}"
},
"description": "{{ contracts[1]['items'][0].description }}",
"description_en": "{{ contracts[1]['items'][0].description_en }}",
"relatedLot": "{{ contracts[1]['items'][0].relatedLot }}",
"quantity": 1,
"unit": {
"code": "{{ contracts[1]['items'][0].unit.code }}",
"name": "{{ contracts[1]['items'][0].unit.name }}",
"value": {
"amount": 10.0,
"valueAddedTaxIncluded": false
}
}
}
]
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@
"name": "ДТП"
},
"status": "draft",
"mode": "test",
"tender": {
"procurementMethod": "open",
"procurementMethodType": "aboveThreshold",
"tenderPeriod": {
"startDate": "XXXX-XX-XXTXX:XX+XX:XX"
"startDate": "{{ from_now_iso() }}"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
"currency": "UAH"
},
"procurementMethodType": "aboveThreshold",
"mode": "test",
"procuringEntity": {
"address": {
"countryName": "Україна",
Expand All @@ -207,14 +208,15 @@
"kind": "special",
"name": "Тестовий заклад #1 м.Київ"
},
"submissionMethodDetails": "{% if submission %}{{ submission }}{% endif %}",
"procurementMethodDetails": "{% if acceleration %}quick, accelerator={{ acceleration }}{% endif %}",
"status": "draft",
"tenderPeriod": {
"endDate": "XXXX-XX-XXTXX:XX+XX:XX",
"startDate": "XXXX-XX-XXTXX:XX+XX:XX"
"startDate": "{{ from_now_iso() }}",
"endDate": "{{ from_now_iso(days=30) }}"
},
"title": "Тестовий опис предмету закупівлі у заголовку тендеру (created with procedure_tools)",
"title_en": "Procurement item test description in procedure title (created with procedure_tools)",
"title_ru": "Тестовое описание предмета закупки в заголовке тендера (created with procedure_tools)",
"value": {
"amount": 500,
"currency": "UAH"
Expand Down
Loading

0 comments on commit f6fad32

Please sign in to comment.