Skip to content

Commit

Permalink
Merge pull request #7 from ivanromakh/a179595119616148_doc_contractin…
Browse files Browse the repository at this point in the history
…g_transfer

Added contracting transfer documentation
  • Loading branch information
vmaksymiv committed Oct 18, 2016
2 parents eedfc23 + 2678c4c commit 94e311a
Show file tree
Hide file tree
Showing 6 changed files with 471 additions and 15 deletions.
49 changes: 48 additions & 1 deletion docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from openprocurement.api.tests.base import (
PrefixedRequestClass, test_tender_data, test_organization
)
from openprocurement.relocation.api.tests.base import OwnershipWebTest
from openprocurement.contracting.api.tests.base import test_contract_data
from openprocurement.relocation.api.tests.base import OwnershipWebTest, test_transfer_data
from webtest import TestApp


Expand Down Expand Up @@ -216,3 +217,49 @@ def test_docs(self):

with open('docs/source/tutorial/get-used-award-complaint-transfer.http', 'w') as self.app.file_obj:
response = self.app.get('/transfers/{}'.format(transfer['id']))

########################
# Contracting transfer #
########################

data = deepcopy(test_contract_data)
tender_token = data['tender_token']
self.app.authorization = ('Basic', ('contracting', ''))

response = self.app.post_json('/contracts', {'data': data})
self.assertEqual(response.status, '201 Created')
self.contract = response.json['data']
self.assertEqual('broker', response.json['data']['owner'])
self.contract_id = self.contract['id']

self.app.authorization = ('Basic', ('broker', ''))
with open('docs/source/tutorial/get-contract-transfer.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/contracts/{}/credentials?acc_token={}'.format(self.contract_id, tender_token),
{'data': ''})
self.assertEqual(response.status, '200 OK')
token = response.json['access']['token']
self.contract_transfer = response.json['access']['transfer']

self.app.authorization = ('Basic', ('broker3', ''))
with open('docs/source/tutorial/create-contract-transfer.http', 'w') as self.app.file_obj:
response = self.app.post_json('/transfers', {"data": test_transfer_data})
self.assertEqual(response.status, '201 Created')
transfer = response.json['data']
self.assertIn('date', transfer)
transfer_creation_date = transfer['date']
new_access_token = response.json['access']['token']
new_transfer_token = response.json['access']['transfer']

with open('docs/source/tutorial/change-contract-ownership.http', 'w') as self.app.file_obj:
response = self.app.post_json('/contracts/{}/ownership'.format(self.contract_id),
{"data": {"id": transfer['id'], 'transfer': self.contract_transfer}})
self.assertEqual(response.status, '200 OK')
self.assertNotIn('transfer', response.json['data'])
self.assertNotIn('transfer_token', response.json['data'])
self.assertEqual('broker3', response.json['data']['owner'])

with open('docs/source/tutorial/modify-contract.http', 'w') as self.app.file_obj:
response = self.app.patch_json('/contracts/{}?acc_token={}'.format(self.contract_id, new_access_token),
{"data": {"description": "broker3 now can change the contract"}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['description'], 'broker3 now can change the contract')
74 changes: 60 additions & 14 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ Tutorial

When customer needs to change current broker this customer should provide new preferred broker with ``transfer`` key for an object (tender, bid, complaint, etc.). Then new broker should create `Transfer` object and send request with `Transfer` ``id`` and ``transfer`` key (received from customer) in order to change object's owner.

Examples for Tender
-------------------

Tender ownership change
-----------------------
~~~~~~~~~~~~~~~~~~~~~~~

Let's view transfer example for tender.


Tender creation
~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^

At first let's create a tender:

Expand All @@ -26,7 +29,7 @@ Note that response's `access` section contains a ``transfer`` key which is used
After tender's registration in CDB broker has to provide its customer with ``transfer`` key.

Transfer creation
~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^

Broker that is going to become new tender owner should create a `Transfer`.

Expand All @@ -41,7 +44,7 @@ Broker that is going to become new tender owner should create a `Transfer`.
:code:

Changing tender's owner
~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^

Pay attention that only broker with appropriate accreditation level can become new owner. Otherwise broker will be forbidden from this action.

Expand All @@ -68,7 +71,7 @@ Let's try to change the tender using ``token`` received on `Transfer` creation:


Bid ownership change
--------------------
~~~~~~~~~~~~~~~~~~~~

Let's submit a bid via current broker:

Expand All @@ -80,7 +83,7 @@ Response contains `access` section with a ``transfer`` key that can be used to c
Current broker has to provide its customer with ``transfer`` key for the bid. Then customer can pass it to new broker.

Transfer creation
~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^

Note that each `Transfer` can be applied only once. New broker (that is going to become new bid owner) should create separate `Transfer` for each owner change:

Expand All @@ -90,7 +93,7 @@ Note that each `Transfer` can be applied only once. New broker (that is going to
`Transfer` object contains new access ``token`` and new ``transfer`` key for the object that will be transferred to new broker.

Changing bid's owner
~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^

Pay attention that only broker with appropriate accreditation level can become new owner. Otherwise broker will be forbidden from this action.

Expand All @@ -111,8 +114,9 @@ Check whether `Transfer` object has successfuly stored bid path in ``usedFor`` p
.. include:: tutorial/get-used-bid-transfer.http
:code:


Complaint ownership change
--------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's submit a complaint via current broker:

Expand All @@ -124,7 +128,7 @@ Response contains `access` section with a ``transfer`` key that can be used to c
Current broker has to provide its customer with ``transfer`` key for the complaint. Then customer can pass it to new broker.

Transfer creation
~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^

Note that each `Transfer` can be applied only once. New broker (that is going to become new complaint owner) should create separate `Transfer` for each owner change:

Expand All @@ -134,7 +138,7 @@ Note that each `Transfer` can be applied only once. New broker (that is going to
`Transfer` object contains new access ``token`` and new ``transfer`` key for the object that will be transferred to new broker.

Changing complaint's owner
~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^

Pay attention that only broker with appropriate accreditation level can become new owner. Otherwise broker will be forbidden from this action.

Expand All @@ -155,8 +159,8 @@ Check whether `Transfer` object has successfuly stored complaint path in ``usedF
.. include:: tutorial/get-used-complaint-transfer.http
:code:

Award omplaint ownership change
--------------------------
Award complaint ownership change
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's submit a award complaint via current broker:

Expand All @@ -168,7 +172,7 @@ Response contains `access` section with a ``transfer`` key that can be used to c
Current broker has to provide its customer with ``transfer`` key for the complaint. Then customer can pass it to new broker.

Transfer creation
~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^

Note that each `Transfer` can be applied only once. New broker (that is going to become new complaint owner) should create separate `Transfer` for each owner change:

Expand All @@ -178,7 +182,7 @@ Note that each `Transfer` can be applied only once. New broker (that is going to
`Transfer` object contains new access ``token`` and new ``transfer`` key for the object that will be transferred to new broker.

Changing complaint's owner
~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^

Pay attention that only broker with appropriate accreditation level can become new owner. Otherwise broker will be forbidden from this action.

Expand All @@ -198,3 +202,45 @@ Check whether `Transfer` object has successfuly stored complaint path in ``usedF

.. include:: tutorial/get-used-award-complaint-transfer.http
:code:

Examples for Contract
----------------------

Contracting ownership change
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's view transfer example for contracting transfer.

Transfer creation
^^^^^^^^^^^^^^^^^

At the first you must know the contract id which you want to transfer

Broker that is going to become new contract owner should create a `Transfer`.

.. include:: tutorial/create-contract-transfer.http
:code:

`Transfer` object contains new access ``token`` and new ``transfer`` token for the object that will be transferred to new broker.

Changing contract's owner
^^^^^^^^^^^^^^^^^^^^^^^^^

To change contract's ownership new broker should send POST request to appropriate `/contracts/id/` with `data` section containing ``id`` of `Transfer` and ``transfer`` token received from customer:

.. include:: tutorial/change-contract-ownership.http
:code:

Updated ``owner`` value indicates that ownership is successfully changed.

Note that new broker has to provide its customer with new ``transfer`` key (generated in `Transfer` object).

After `Transfer` is applied it stores contract path in ``usedFor`` property:

.. include:: tutorial/get-used-contract-transfer.http
:code:

Let's try to change the contract using ``token`` received on `Transfer` creation:

.. include:: tutorial/modify-contract.http
:code:
113 changes: 113 additions & 0 deletions docs/source/tutorial/change-contract-ownership.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
POST /api/2.3/contracts/0bbe02412aa1409da48c1ff1c9998515/ownership HTTP/1.0
Authorization: Basic YnJva2VyMzo=
Content-Length: 100
Content-Type: application/json
Host: api-sandbox.openprocurement.org
DATA:
{
"data": {
"transfer": "6a8d3890c44041d8ba6351763efa9ef2",
"id": "142974ce839c4b6cfd836abd79002f87"
}
}

Response: 200 OK
Content-Type: application/json; charset=UTF-8
{
"data": {
"status": "active",
"items": [
{
"description": "футляри до державних нагород",
"classification": {
"scheme": "CPV",
"description": "Cartons",
"id": "44617100-9"
},
"additionalClassifications": [
{
"scheme": "ДКПП",
"id": "17.21.1",
"description": "папір і картон гофровані, паперова й картонна тара"
}
],
"deliveryAddress": {
"postalCode": "79000",
"countryName": "Україна",
"streetAddress": "вул. Банкова 1",
"region": "м. Київ",
"locality": "м. Київ"
},
"deliveryDate": {
"startDate": "2016-03-20T18:47:47.136678+02:00",
"endDate": "2016-03-23T18:47:47.136678+02:00"
},
"id": "c6c6e8ed4b1542e4bf13d3f98ec5ab59",
"unit": {
"code": "44617100-9",
"name": "item"
},
"quantity": 5
}
],
"suppliers": [
{
"contactPoint": {
"email": "aagt@gmail.com",
"telephone": "+380 (322) 91-69-30",
"name": "Андрій Олексюк"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00137226",
"uri": "http://www.sc.gov.ua/"
},
"name": "ДКП «Книга»",
"address": {
"postalCode": "79013",
"countryName": "Україна",
"streetAddress": "вул. Островського, 34",
"region": "м. Львів",
"locality": "м. Львів"
}
}
],
"contractNumber": "contract #13111",
"period": {
"startDate": "2016-03-18T18:47:47.155143+02:00",
"endDate": "2017-03-18T18:47:47.155143+02:00"
},
"value": {
"currency": "UAH",
"amount": 238.0,
"valueAddedTaxIncluded": true
},
"id": "0bbe02412aa1409da48c1ff1c9998515",
"owner": "broker3",
"procuringEntity": {
"contactPoint": {
"name": "Державне управління справами",
"telephone": "0440000000"
},
"identifier": {
"scheme": "UA-EDR",
"id": "00037256",
"uri": "http://www.dus.gov.ua/"
},
"name": "Державне управління справами",
"address": {
"postalCode": "01220",
"countryName": "Україна",
"streetAddress": "вул. Банкова, 11, корпус 1",
"region": "м. Київ",
"locality": "м. Київ"
}
},
"contractID": "UA-2016-03-18-000001-1",
"dateSigned": "2016-03-18T18:48:05.762961+02:00",
"awardID": "8481d7eb01694c25b18658036c236c5d",
"dateModified": "2016-09-14T18:22:39.266014+03:00",
"tender_id": "3fc5b26b56484df985b02d812b9c590b"
}
}

23 changes: 23 additions & 0 deletions docs/source/tutorial/create-contract-transfer.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
POST /api/2.3/transfers HTTP/1.0
Authorization: Basic YnJva2VyMzo=
Content-Length: 12
Content-Type: application/json
Host: api-sandbox.openprocurement.org
DATA:
{
"data": {}
}

Response: 201 Created
Content-Type: application/json; charset=UTF-8
{
"access": {
"transfer": "a6afa28816874e53bbc3fde11eec0028",
"token": "2bed73f61da14db9abb074b234c00c69"
},
"data": {
"date": "2016-09-14T18:22:39.222959+03:00",
"id": "142974ce839c4b6cfd836abd79002f87"
}
}

0 comments on commit 94e311a

Please sign in to comment.