Skip to content

Commit

Permalink
Merged a147460966605399_set_date_on_status
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarasz committed Jul 8, 2016
1 parent b331313 commit 187c376
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions openprocurement/tender/limited/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class Options:
description = StringType()
description_en = StringType()
description_ru = StringType()
date = IsoDateTimeType()
tenderID = StringType() # TenderID should always be the same as the OCID. It is included to make the flattened data structure more convenient.
items = ListType(ModelType(Item), required=True, min_size=1, validators=[validate_cpv_group, validate_items_uniq]) # The goods and services to be purchased, broken into line items wherever possible. Items should not be duplicated, but a quantity of 2 specified instead.
value = ModelType(Value, required=True) # The total estimated value of the procurement.
Expand Down Expand Up @@ -179,6 +180,9 @@ def __acl__(self):
(Allow, '{}_{}'.format(self.owner, self.owner_token), 'edit_complaint'),
]

def initialize(self):
self.date = get_now()

def validate_procurementMethodDetails(self, *args, **kw):
if self.mode and self.mode == 'test' and self.procurementMethodDetails and self.procurementMethodDetails != '':
raise ValidationError(u"procurementMethodDetails should be used with mode test")
Expand Down
4 changes: 2 additions & 2 deletions openprocurement/tender/limited/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def test_create_tender_generated(self):
tender = response.json['data']
fields = [u'id', u'dateModified', u'tenderID', u'status', u'items',
u'value', u'procuringEntity', u'owner', u'procurementMethod',
u'procurementMethodType', u'title']
u'procurementMethodType', u'title', u'date']
if u'procurementMethodDetails' in self.initial_data:
fields.append(u'procurementMethodDetails')
if "negotiation" == self.initial_data['procurementMethodType']:
Expand Down Expand Up @@ -583,7 +583,7 @@ def test_create_tender(self):
if "negotiation" in self.initial_data['procurementMethodType']:
tender_set.remove(u'causeDescription')
self.assertEqual(tender_set - set(test_tender_data), set(
[u'id', u'dateModified', u'owner', u'tenderID', u'status', u'procurementMethod']))
[u'id', u'date', u'dateModified', u'owner', u'tenderID', u'status', u'procurementMethod']))
self.assertIn(tender['id'], response.headers['Location'])

response = self.app.get('/tenders/{}'.format(tender['id']))
Expand Down
2 changes: 2 additions & 0 deletions openprocurement/tender/limited/views/award.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def patch(self):
tender.contracts.append(type(tender).contracts.model_class({
'awardID': award.id,
'suppliers': award.suppliers,
'date': get_now(),
'value': award.value,
'items': tender.items,
'contractID': '{}-{}{}'.format(tender.tenderID, self.server_id, len(tender.contracts) +1) }))
Expand Down Expand Up @@ -514,6 +515,7 @@ def patch(self):
tender.contracts.append(type(tender).contracts.model_class({
'awardID': award.id,
'suppliers': award.suppliers,
'date': get_now(),
'value': award.value,
'items': tender.items,
'contractID': '{}-{}{}'.format(tender.tenderID, self.server_id, len(tender.contracts) +1) }))
Expand Down
1 change: 1 addition & 0 deletions openprocurement/tender/limited/views/award_complaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def collection_post(self):
self.request.errors.status = 403
return
complaint = self.request.validated['complaint']
complaint.date = get_now()
complaint.type = 'complaint'
if complaint.status == 'pending':
complaint.dateSubmitted = get_now()
Expand Down
2 changes: 2 additions & 0 deletions openprocurement/tender/limited/views/cancellation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from openprocurement.api.models import get_now
from openprocurement.api.utils import (
apply_patch,
save_tender,
Expand Down Expand Up @@ -30,6 +31,7 @@ def collection_post(self):
self.request.errors.status = 403
return
cancellation = self.request.validated['cancellation']
cancellation.date = get_now()
if cancellation.status == 'active':
tender.status = 'cancelled'
tender.cancellations.append(cancellation)
Expand Down

0 comments on commit 187c376

Please sign in to comment.