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
9d0d3d73
Commit
9d0d3d73
authored
Jul 19, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: remaining_loan_time o book loan api
parent
a61ee99f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
serializers.py
api/loans/serializers.py
+7
-0
No files found.
api/loans/serializers.py
View file @
9d0d3d73
...
@@ -9,6 +9,13 @@ from ..auth.serializers import MemberSerializer
...
@@ -9,6 +9,13 @@ from ..auth.serializers import MemberSerializer
class
BookLoanSerializer
(
serializers
.
ModelSerializer
):
class
BookLoanSerializer
(
serializers
.
ModelSerializer
):
book_detail
=
BookSerializer
(
source
=
"book"
,
read_only
=
True
)
book_detail
=
BookSerializer
(
source
=
"book"
,
read_only
=
True
)
member_detail
=
MemberSerializer
(
source
=
"member"
,
read_only
=
True
)
member_detail
=
MemberSerializer
(
source
=
"member"
,
read_only
=
True
)
remaining_loan_time
=
serializers
.
DateTimeField
(
read_only
=
True
)
def
to_representation
(
self
,
instance
):
data
=
super
()
.
to_representation
(
instance
)
remaining_loan_time
=
instance
.
due_date
.
day
-
timezone
.
now
()
.
day
data
[
"remaining_loan_time"
]
=
str
(
remaining_loan_time
)
+
" days left"
return
data
class
Meta
:
class
Meta
:
model
=
BookLoan
model
=
BookLoan
...
...
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