mirror of
https://github.com/yawaflua/SusMarket.git
synced 2025-12-08 19:49:36 +02:00
поправил косяки
This commit is contained in:
@@ -5,13 +5,15 @@ urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
path('info', views.index, name='info'),
|
||||
path('profile', views.index, name='profile'),
|
||||
path('product', views.index, name='product'),
|
||||
path('product/<int:product>', views.index, name='product'),
|
||||
path('payment', views.index, name='payment'),
|
||||
path('scam', views.index, name='scam'),
|
||||
path('api/get/category', views.category, name='category'),
|
||||
path('api/get/products', views.products, name='products'),
|
||||
path('api/get/reviews/<int:product>', views.reviews, name='reviews'),
|
||||
path('api/post/user/<str:login>/<str:password>', views.register_user, name='register-user'),
|
||||
path('api/post/review/<str:commentary>/<int:rate>/<int:product>/<str:icon>/<int:user_id>', views.post_review, name='post-review'),
|
||||
path('api/post/check/user/<str:login>', views.check_user, name='check-user'),
|
||||
path('api/get/user/<str:login>/<str:password>', views.user, name='get-user')
|
||||
path('api/get/user/<str:login>/<str:password>', views.user, name='get-user'),
|
||||
path('api/get/user/<int:user_id>', views.user_by_id, name='get-user-by-id')
|
||||
]
|
||||
@@ -30,6 +30,11 @@ def register_user(request: HttpRequest, login: str, password: str):
|
||||
return HttpResponse('{error: "Null"}')
|
||||
|
||||
|
||||
def post_review(request: HttpRequest, commentary: str, rate: int, product: int, icon: str, user_id: int):
|
||||
Review.objects.create(commentary=commentary, rate=rate, product_id=product, icons=icon, user_id=user_id)
|
||||
return HttpResponse('{error: "Null"}')
|
||||
|
||||
|
||||
def check_user(request: HttpRequest, login: str):
|
||||
checkObj = {"status": True if User.objects.filter(login=login).first() is None else False}
|
||||
return JsonResponse(checkObj)
|
||||
@@ -38,3 +43,8 @@ def check_user(request: HttpRequest, login: str):
|
||||
def user(request: HttpRequest, login: str, password: str):
|
||||
userObj = {"user": User.objects.filter(login=login, password=hashlib.md5(password).hexdigest()).first()}
|
||||
return JsonResponse(userObj)
|
||||
|
||||
|
||||
def user_by_id(request: HttpRequest, user_id: int):
|
||||
userObj = {"user": User.objects.filter(id=user_id).first()}
|
||||
return JsonResponse(userObj)
|
||||
|
||||
Reference in New Issue
Block a user