Commit 8c784eab authored by Ilham Maulana's avatar Ilham Maulana 💻

fix: member loans ordering

parent 5ce8e169
......@@ -278,7 +278,7 @@ def checkAuthSessionView(request):
@csrf_exempt
def memberLoanView(request):
header_authorization = request.headers.get("Authorization")
book_loans = BookLoan.objects.all()
book_loans = BookLoan.objects.all().order_by("loan_date")
if request.method == "GET":
now = timezone.now()
......@@ -309,9 +309,7 @@ def memberLoanView(request):
)
if overdue:
loans = loans.filter(due_date__lte=now, return_date=None).order_by(
"loan_date"
)
loans = loans.filter(due_date__lte=now, return_date=None)
paginator = Paginator(loans, 10)
page_obj = paginator.get_page(page_number)
......
......@@ -2,6 +2,7 @@ from django.http import JsonResponse
from django.core.paginator import Paginator
from django.views.decorators.csrf import csrf_exempt
from config.constants import host_name
from book.models import Book, Category
......@@ -30,7 +31,10 @@ def bookView(request):
"title": book_item.title,
"author": book_item.author,
"description": book_item.description,
"cover_image": "http://127.0.0.1:8000" + book_item.cover_image.url,
"cover_image": "http://"
+ host_name
+ ":8000"
+ book_item.cover_image.url,
"category": {
"name": book_item.category.name,
},
......@@ -41,7 +45,10 @@ def bookView(request):
"title": book_item.title,
"author": book_item.author,
"description": book_item.description,
"cover_image": "http://127.0.0.1:8000" + book_item.cover_image.url,
"cover_image": "http://"
+ host_name
+ ":8000"
+ book_item.cover_image.url,
}
data.append(book)
......
host_name = "127.0.0.1"
......@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
import os
from pathlib import Path
from .constants import host_name
from dotenv import load_dotenv
load_dotenv()
......@@ -31,7 +33,7 @@ DEBUG = True
ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"192.168.2.252",
host_name,
"library_app.ilhammaulana.me",
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment