Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
8c784eab
Commit
8c784eab
authored
Aug 12, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: member loans ordering
parent
5ce8e169
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
7 deletions
+15
-7
views.py
api/auth/views.py
+2
-4
views.py
api/book/views.py
+9
-2
constants.py
config/constants.py
+1
-0
settings.py
config/settings.py
+3
-1
No files found.
api/auth/views.py
View file @
8c784eab
...
@@ -278,7 +278,7 @@ def checkAuthSessionView(request):
...
@@ -278,7 +278,7 @@ def checkAuthSessionView(request):
@
csrf_exempt
@
csrf_exempt
def
memberLoanView
(
request
):
def
memberLoanView
(
request
):
header_authorization
=
request
.
headers
.
get
(
"Authorization"
)
header_authorization
=
request
.
headers
.
get
(
"Authorization"
)
book_loans
=
BookLoan
.
objects
.
all
()
book_loans
=
BookLoan
.
objects
.
all
()
.
order_by
(
"loan_date"
)
if
request
.
method
==
"GET"
:
if
request
.
method
==
"GET"
:
now
=
timezone
.
now
()
now
=
timezone
.
now
()
...
@@ -309,9 +309,7 @@ def memberLoanView(request):
...
@@ -309,9 +309,7 @@ def memberLoanView(request):
)
)
if
overdue
:
if
overdue
:
loans
=
loans
.
filter
(
due_date__lte
=
now
,
return_date
=
None
)
.
order_by
(
loans
=
loans
.
filter
(
due_date__lte
=
now
,
return_date
=
None
)
"loan_date"
)
paginator
=
Paginator
(
loans
,
10
)
paginator
=
Paginator
(
loans
,
10
)
page_obj
=
paginator
.
get_page
(
page_number
)
page_obj
=
paginator
.
get_page
(
page_number
)
...
...
api/book/views.py
View file @
8c784eab
...
@@ -2,6 +2,7 @@ from django.http import JsonResponse
...
@@ -2,6 +2,7 @@ from django.http import JsonResponse
from
django.core.paginator
import
Paginator
from
django.core.paginator
import
Paginator
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.csrf
import
csrf_exempt
from
config.constants
import
host_name
from
book.models
import
Book
,
Category
from
book.models
import
Book
,
Category
...
@@ -30,7 +31,10 @@ def bookView(request):
...
@@ -30,7 +31,10 @@ def bookView(request):
"title"
:
book_item
.
title
,
"title"
:
book_item
.
title
,
"author"
:
book_item
.
author
,
"author"
:
book_item
.
author
,
"description"
:
book_item
.
description
,
"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"
:
{
"category"
:
{
"name"
:
book_item
.
category
.
name
,
"name"
:
book_item
.
category
.
name
,
},
},
...
@@ -41,7 +45,10 @@ def bookView(request):
...
@@ -41,7 +45,10 @@ def bookView(request):
"title"
:
book_item
.
title
,
"title"
:
book_item
.
title
,
"author"
:
book_item
.
author
,
"author"
:
book_item
.
author
,
"description"
:
book_item
.
description
,
"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
)
data
.
append
(
book
)
...
...
config/constants.py
0 → 100644
View file @
8c784eab
host_name
=
"127.0.0.1"
config/settings.py
View file @
8c784eab
...
@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
...
@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
import
os
import
os
from
pathlib
import
Path
from
pathlib
import
Path
from
.constants
import
host_name
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
load_dotenv
()
load_dotenv
()
...
@@ -31,7 +33,7 @@ DEBUG = True
...
@@ -31,7 +33,7 @@ DEBUG = True
ALLOWED_HOSTS
=
[
ALLOWED_HOSTS
=
[
"localhost"
,
"localhost"
,
"127.0.0.1"
,
"127.0.0.1"
,
"192.168.2.252"
,
host_name
,
"library_app.ilhammaulana.me"
,
"library_app.ilhammaulana.me"
,
]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment