Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Auction logic to view. Auto calculation of auction fields. Rectification period. procurementMethodDetails field. submissionMethodDetails field #7

Merged
merged 30 commits into from
Apr 27, 2018

Conversation

oleksiyVeretiuk
Copy link
Contributor

@oleksiyVeretiuk oleksiyVeretiuk commented Apr 25, 2018

@oleksiyVeretiuk oleksiyVeretiuk changed the title Move Auction logic to view. Auto calculation of of auction fields Move Auction logic to view. Auto calculation of auction fields Apr 26, 2018
@oleksiyVeretiuk oleksiyVeretiuk changed the title Move Auction logic to view. Auto calculation of auction fields Move Auction logic to view. Auto calculation of auction fields. Rectification period. procurementMethodDetails field Apr 26, 2018
@coveralls
Copy link

coveralls commented Apr 26, 2018

Pull Request Test Coverage Report for Build 38

  • 513 of 538 (95.35%) changed or added relevant lines in 15 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 95.971%

Changes Missing Coverage Covered Lines Changed/Added Lines %
openregistry/lots/loki/views/lot_auction.py 17 18 94.44%
openregistry/lots/loki/validation.py 31 32 96.88%
openregistry/lots/loki/models.py 40 43 93.02%
openregistry/lots/loki/tests/auction.py 17 21 80.95%
openregistry/lots/loki/tests/blanks/auction_blanks.py 244 260 93.85%
Totals Coverage Status
Change from base Build 25: -0.02%
Covered Lines: 1858
Relevant Lines: 1936

💛 - Coveralls

@oleksiyVeretiuk oleksiyVeretiuk changed the title Move Auction logic to view. Auto calculation of auction fields. Rectification period. procurementMethodDetails field Move Auction logic to view. Auto calculation of auction fields. Rectification period. procurementMethodDetails field. submissionMethodDetails field Apr 26, 2018
@@ -25,5 +29,15 @@ class LokiLotManagerAdapter(LotManagerAdapter):
validate_decision_post,
)

def _set_rectificationPeriod(self, request):
if request.validated['data'].get('status') == 'pending' and not request.context.rectificationPeriod:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Цей if повинен бути в change_lot

@@ -25,5 +29,15 @@ class LokiLotManagerAdapter(LotManagerAdapter):
validate_decision_post,
)

def _set_rectificationPeriod(self, request):
if request.validated['data'].get('status') == 'pending' and not request.context.rectificationPeriod:
request.context.rectificationPeriod = type(request.context).rectificationPeriod.model_class()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Спочатку формуєш період, потім передаєш його в context

@@ -67,20 +68,41 @@ class AuctionParameters(Model):
if SANDBOX_MODE:
procurementMethodDetails = StringType()

def validate_dutchSteps(self, data, value):
if data['type'] == 'english' and value:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if data['type'] != 'insider'

guarantee = ModelType(Guarantee, required=True)
status = StringType()
procurementMethodType = StringType(choices=['sellout.english', 'sellout.insider'])
tenderAttempts = IntType(max_value=3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min?

value = ModelType(Value, required=True)
minimalStep = ModelType(Value, required=True)
guarantee = ModelType(Guarantee, required=True)
status = StringType()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Довільна стрінга?

Copy link
Contributor Author

@oleksiyVeretiuk oleksiyVeretiuk Apr 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По логіці тут повинен був бути choices зі статусами з процедури для SSP, але чи вони вже є?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, статуси є. Але графіку зі флоу ще нема

@@ -85,3 +86,56 @@ def validate_deleted_status(request, error_handler, **kwargs):
"only when asset have at least one document with \'cancellationDetails\' documentType")
request.errors.status = 403
raise error_handler(request)


def validate_update_item_in_not_allowed_status(request, error_handler, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not_allowed_status-и можна винести в конфігуратор і перенести цю функцію в core

Copy link
Contributor Author

@oleksiyVeretiuk oleksiyVeretiuk Apr 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

під конфігуратором ти маєш на увазі LotManager чи LokiLotConfigurator?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Список статусів, у яких не можна оновлювати items



def validate_update_auction_in_not_allowed_status(request, error_handler, **kwargs):
is_convoy = bool(request.authenticated_role != 'convoy')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_convoy = bool(не конвой) ?

'Can\'t update item in current ({}) lot status'.format(request.validated['lot_status']))


def validate_verification_status(request, error_handler, **kwargs):

This comment was marked as resolved.

def patch(self):
"""Lot Auction Update"""
if apply_patch(self.request, src=self.request.context.serialize()):
update_file_content_type(self.request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поглянь на функцію update_file_content_type

self.LOGGER.info('Updated lot item {}'.format(self.request.context.id),
extra=context_unpack(self.request, {'MESSAGE_ID': 'lot_auction_patch'}))
return {'data': self.request.context.serialize("view")}
return {'data': self.request.context.serialize("view")}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Другого return не потрібно

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Під час тестів натикнувся на таку штуку: коли патчиш ідентичні дані з тими, які вже є в лоті apply_patch повертає не True і через це в response.json лежить None

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так, все правильно

auction.auctionParameters = auctionParameters_class()
if auction_type == 'sellout.english':
auction.auctionParameters.type = 'english'
if auction_type == 'sellout.insider':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elif

auction_class = lot.__class__.auctions.model_class
auctionParameters_class = lot.__class__.auctions.model_class.auctionParameters.model_class
for tenderAttempts, auction_type in enumerate(auction_types, 1):
auction = auction_class()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поглянь на make_award функцію, об'єкт класу можна створити передавши йому дані

self._validate(request, self.change_validation)
if request.validated['data'].get('status') == 'pending' and not request.context.rectificationPeriod:
self._set_rectificationPeriod(request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

@@ -62,25 +65,44 @@ class AccountDetails(Model):


class AuctionParameters(Model):
class Options:
roles = auctionParameters_roles

type = StringType(choices=['english', 'insider'])
dutchSteps = IntType(default=None, min_value=1, max_value=100)
if SANDBOX_MODE:
procurementMethodDetails = StringType()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Це значення аукціону, а не AuctionParameters

Copy link
Contributor Author

@oleksiyVeretiuk oleksiyVeretiuk Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мається на увазі, що procurementMethodDetails повинен бути в auction?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так

english = auctions[0]
second_english = auctions[1]
insider = auctions[2]
auto_calculated_fields = filter(lambda f: english[f], auto_calculated_fields)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А якщо одного з полів не буде? KeyError

Copy link
Contributor Author

@oleksiyVeretiuk oleksiyVeretiuk Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Це ж schematics модель тому в поля, якого немає значення буде none. Проте переплавлю на getattr

@leits leits merged commit 49f5155 into openprocurement:master Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants