From 00d2b2e81f46ac3bbe12d08dcafb623c9da60755 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 16 Jun 2021 11:55:05 +0200 Subject: [PATCH 1/2] fixing bug taiga 2280 --- ereuse_devicehub/resources/action/schemas.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 8922f52c..fc168814 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -577,11 +577,19 @@ class Trade(ActionWithMultipleDevices): @validates_schema def validate_email_users(self, data: dict): """We need at least one user""" - if not (data['user_from_email'] or data['user_to_email']): + confirm = data['confirm'] + user_from = data['user_from_email'] + user_to = data['user_to_email'] + + if not (user_from or user_to): txt = "you need one user from or user to for to do a trade" raise ValidationError(txt) - if not g.user.email in [data['user_from_email'], data['user_to_email']]: + if confirm and not (user_from and user_to): + txt = "you need one user for to do a trade" + raise ValidationError(txt) + + if not g.user.email in [user_from, user_to]: txt = "you need to be one of participate of the action" raise ValidationError(txt) @@ -596,7 +604,8 @@ class Trade(ActionWithMultipleDevices): txt = "you need a code to be able to do the traceability" raise ValidationError(txt) - data['code'] = data['code'].replace('@', '_') + if not data['confirm']: + data['code'] = data['code'].replace('@', '_') class InitTransfer(Trade): From 5dc1b795968568d5bd2d0bd850c1c8ccf0d40728 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 16 Jun 2021 17:07:00 +0200 Subject: [PATCH 2/2] fixing bug 2281 --- ereuse_devicehub/resources/lot/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ereuse_devicehub/resources/lot/views.py b/ereuse_devicehub/resources/lot/views.py index f5b80ae3..9bff204b 100644 --- a/ereuse_devicehub/resources/lot/views.py +++ b/ereuse_devicehub/resources/lot/views.py @@ -89,7 +89,7 @@ class LotView(View): query = self.visibility_filter(query) if args['search']: query = query.filter(Lot.name.ilike(args['search'] + '%')) - lots = query.paginate(per_page=6 if args['search'] else 30) + lots = query.paginate(per_page=6 if args['search'] else query.count()) return things_response( self.schema.dump(lots.items, many=True, nested=2), lots.page, lots.per_page, lots.total, lots.prev_num, lots.next_num