Features: 1) Add support for filtering objects by SKU in get_object method; 2) Introduce handling for new feedbacks and do_feedback in additional and serializers;
Fixes: 1) Adjust import order in `viewsets.py` to match project convention; 2) Correct schema name from `seo` to `seo_meta` in documentation; Extra: 1) Refactor SEO schemas import order for better readability; 2) Update `additional` field structure with consistent formatting.
This commit is contained in:
parent
f95f640a06
commit
d44bbdd920
2 changed files with 14 additions and 7 deletions
|
|
@ -549,7 +549,7 @@ PRODUCT_SCHEMA = {
|
|||
**BASE_ERRORS,
|
||||
},
|
||||
),
|
||||
"seo": extend_schema(
|
||||
"seo_meta": extend_schema(
|
||||
summary=_("SEO Meta snapshot"),
|
||||
description=_("returns a snapshot of the product's SEO meta data"),
|
||||
parameters=[
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from uuid import UUID
|
|||
|
||||
from constance import config
|
||||
from django.conf import settings
|
||||
from django.db.models import Q, Prefetch
|
||||
from django.db.models import Prefetch, Q
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.decorators import method_decorator
|
||||
|
|
@ -109,13 +109,13 @@ from core.utils import format_attributes
|
|||
from core.utils.messages import permission_denied_message
|
||||
from core.utils.nominatim import fetch_address_suggestions
|
||||
from core.utils.seo_builders import (
|
||||
org_schema,
|
||||
website_schema,
|
||||
brand_schema,
|
||||
breadcrumb_schema,
|
||||
product_schema,
|
||||
category_schema,
|
||||
item_list_schema,
|
||||
brand_schema,
|
||||
org_schema,
|
||||
product_schema,
|
||||
website_schema,
|
||||
)
|
||||
from evibes.settings import DEBUG
|
||||
from payments.serializers import TransactionProcessSerializer
|
||||
|
|
@ -536,7 +536,10 @@ class ProductViewSet(EvibesViewSet):
|
|||
}
|
||||
lookup_field = "lookup_value"
|
||||
lookup_url_kwarg = "lookup_value"
|
||||
additional = {"seo_meta": "ALLOW"}
|
||||
additional = {
|
||||
"seo_meta": "ALLOW",
|
||||
"feedbacks": "ALLOW",
|
||||
}
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
|
|
@ -565,6 +568,9 @@ class ProductViewSet(EvibesViewSet):
|
|||
if not obj:
|
||||
obj = queryset.filter(slug=lookup_value).first()
|
||||
|
||||
if not obj:
|
||||
obj = queryset.filter(sku=lookup_value).first()
|
||||
|
||||
if not obj:
|
||||
name = "Product"
|
||||
raise Http404(f"{name} does not exist: {lookup_value}")
|
||||
|
|
@ -951,6 +957,7 @@ class OrderProductViewSet(EvibesViewSet):
|
|||
"list": OrderProductSimpleSerializer,
|
||||
"do_feedback": DoFeedbackSerializer,
|
||||
}
|
||||
additional = {"do_feedback": "ALLOW"}
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super().get_queryset()
|
||||
|
|
|
|||
Loading…
Reference in a new issue