fix chat route
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from django.urls import path
|
from django.urls import path, re_path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('product/<int:pk>', views.ProductChatView.as_view(), name='product-chat-view'),
|
re_path(r'^product/(?P<slug>[\w\u0600-\u06FF\-]+)$', views.ProductChatView.as_view(), name='product-chat-view'),
|
||||||
]
|
]
|
||||||
@@ -94,12 +94,12 @@ class ProductChatView(APIView):
|
|||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
pagination_class = StructurePagination
|
pagination_class = StructurePagination
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, slug):
|
||||||
"""
|
"""
|
||||||
Retrieve all messages for a product chat.
|
Retrieve all messages for a product chat.
|
||||||
"""
|
"""
|
||||||
user = request.user
|
user = request.user
|
||||||
product = get_object_or_404(ProductModel, id=pk)
|
product = get_object_or_404(ProductModel, slug=slug)
|
||||||
chat, created = ProductChatModel.objects.get_or_create(user=user, product=product)
|
chat, created = ProductChatModel.objects.get_or_create(user=user, product=product)
|
||||||
|
|
||||||
client = openai.OpenAI(api_key=settings.OPENAI_API_KEY)
|
client = openai.OpenAI(api_key=settings.OPENAI_API_KEY)
|
||||||
|
|||||||
Reference in New Issue
Block a user