Add support for human_readable_id in filters and models
Added a `human_readable_id` filter to the `OrderFilter` class and enabled ordering by this field. Updated the `create_customer_payload` method to include the `is_business` attribute, ensuring compatibility with new functionality.
This commit is contained in:
parent
65812190a2
commit
3e53224092
5 changed files with 8 additions and 2 deletions
|
|
@ -212,10 +212,14 @@ class OrderFilter(FilterSet):
|
|||
user_email = CharFilter(field_name="user__email", lookup_expr="iexact")
|
||||
user = UUIDFilter(field_name="user__uuid", lookup_expr="exact")
|
||||
status = CharFilter(field_name="status", lookup_expr="icontains", label="Status")
|
||||
human_readable_id = CharFilter(field_name="human_readable_id", lookup_expr="exact")
|
||||
|
||||
order_by = OrderingFilter(
|
||||
fields=(
|
||||
("uuid", "uuid"),
|
||||
("human_readable_id", "human_readable_id"),
|
||||
("user_email", "user_email"),
|
||||
("user", "user"),
|
||||
("status", "status"),
|
||||
("created", "created"),
|
||||
("modified", "modified"),
|
||||
|
|
@ -226,7 +230,7 @@ class OrderFilter(FilterSet):
|
|||
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = ["uuid", "user_email", "user", "status", "order_by"]
|
||||
fields = ["uuid", "human_readable_id", "user_email", "user", "status", "order_by"]
|
||||
|
||||
|
||||
class WishlistFilter(FilterSet):
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1140,7 +1140,7 @@ msgstr "Временная метка, когда заказ был заверш
|
|||
|
||||
#: core/models.py:491
|
||||
msgid "buy time"
|
||||
msgstr "Выиграть время"
|
||||
msgstr "Время покупки"
|
||||
|
||||
#: core/models.py:498
|
||||
msgid "a human-readable identifier for the order"
|
||||
|
|
|
|||
|
|
@ -741,6 +741,7 @@ class Order(NiceModel):
|
|||
"customer_name": customer_name,
|
||||
"customer_email": customer_email,
|
||||
"customer_phone_number": customer_phone_number,
|
||||
"is_business": kwargs.get("is_business", False),
|
||||
}
|
||||
)
|
||||
self.save()
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ class BuyAsBusinessView(APIView):
|
|||
customer_billing_address=serializer.validated_data.get("customer_billing_address"),
|
||||
customer_shipping_address=serializer.validated_data.get("customer_shipping_address"),
|
||||
payment_method=serializer.validated_data.get("payment_method"),
|
||||
is_business=True,
|
||||
)
|
||||
return Response(status=status.HTTP_202_ACCEPTED, data=TransactionProcessSerializer(transaction).data)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue