-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
Pull Request Test Coverage Report for Build 38
💛 - Coveralls |
openregistry/lots/loki/adapters.py
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Цей if повинен бути в change_lot
openregistry/lots/loki/adapters.py
Outdated
@@ -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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спочатку формуєш період, потім передаєш його в context
openregistry/lots/loki/models.py
Outdated
@@ -67,20 +68,41 @@ class AuctionParameters(Model): | |||
if SANDBOX_MODE: | |||
procurementMethodDetails = StringType() | |||
|
|||
def validate_dutchSteps(self, data, value): | |||
if data['type'] == 'english' and value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if data['type'] != 'insider'
openregistry/lots/loki/models.py
Outdated
guarantee = ModelType(Guarantee, required=True) | ||
status = StringType() | ||
procurementMethodType = StringType(choices=['sellout.english', 'sellout.insider']) | ||
tenderAttempts = IntType(max_value=3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
min?
openregistry/lots/loki/models.py
Outdated
value = ModelType(Value, required=True) | ||
minimalStep = ModelType(Value, required=True) | ||
guarantee = ModelType(Guarantee, required=True) | ||
status = StringType() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Довільна стрінга?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По логіці тут повинен був бути choices зі статусами з процедури для SSP, але чи вони вже є?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так, статуси є. Але графіку зі флоу ще нема
openregistry/lots/loki/validation.py
Outdated
@@ -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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not_allowed_status-и можна винести в конфігуратор і перенести цю функцію в core
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
під конфігуратором ти маєш на увазі LotManager чи LokiLotConfigurator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Список статусів, у яких не можна оновлювати items
openregistry/lots/loki/validation.py
Outdated
|
||
|
||
def validate_update_auction_in_not_allowed_status(request, error_handler, **kwargs): | ||
is_convoy = bool(request.authenticated_role != 'convoy') |
There was a problem hiding this comment.
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.
This comment was marked as resolved.
Sorry, something went wrong.
def patch(self): | ||
"""Lot Auction Update""" | ||
if apply_patch(self.request, src=self.request.context.serialize()): | ||
update_file_content_type(self.request) |
There was a problem hiding this comment.
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")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Другого return не потрібно
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так, все правильно
openregistry/lots/loki/adapters.py
Outdated
auction.auctionParameters = auctionParameters_class() | ||
if auction_type == 'sellout.english': | ||
auction.auctionParameters.type = 'english' | ||
if auction_type == 'sellout.insider': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif
openregistry/lots/loki/adapters.py
Outdated
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
openregistry/lots/loki/models.py
Outdated
@@ -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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Це значення аукціону, а не AuctionParameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мається на увазі, що procurementMethodDetails повинен бути в auction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так
openregistry/lots/loki/models.py
Outdated
english = auctions[0] | ||
second_english = auctions[1] | ||
insider = auctions[2] | ||
auto_calculated_fields = filter(lambda f: english[f], auto_calculated_fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А якщо одного з полів не буде? KeyError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Це ж schematics модель тому в поля, якого немає значення буде none. Проте переплавлю на getattr
depends on
openprocurement/openregistry.lots.core#31
openprocurement/openprocurement.api#299