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
c448901d
Commit
c448901d
authored
Aug 05, 2024
by
Ilham Maulana
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remaining loan
parent
3cc51702
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
6 deletions
+16
-6
views.py
dashboard/views.py
+10
-3
book_loan_table_data.html
loans/templates/book_loan_table_data.html
+1
-3
views.py
loans/views.py
+5
-0
No files found.
dashboard/views.py
View file @
c448901d
...
@@ -34,6 +34,11 @@ class OverduedLoanView(ListView):
...
@@ -34,6 +34,11 @@ class OverduedLoanView(ListView):
return
queryset
return
queryset
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
"now"
]
=
timezone
.
now
()
return
context
class
UpcomingLoanView
(
ListView
):
class
UpcomingLoanView
(
ListView
):
model
=
BookLoan
model
=
BookLoan
...
@@ -67,11 +72,13 @@ class UpcomingLoanView(ListView):
...
@@ -67,11 +72,13 @@ class UpcomingLoanView(ListView):
elif
order
==
"old"
:
elif
order
==
"old"
:
queryset
=
queryset
.
order_by
(
"created_at"
)
queryset
=
queryset
.
order_by
(
"created_at"
)
today
=
timezone
.
now
()
queryset
=
queryset
.
annotate
(
remaining_loan_time
=
(
F
(
"due_date"
)
-
today
))
return
queryset
return
queryset
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
"now"
]
=
timezone
.
now
()
return
context
class
HomePage
(
TemplateView
):
class
HomePage
(
TemplateView
):
template_name
=
"homepage.html"
template_name
=
"homepage.html"
...
...
loans/templates/book_loan_table_data.html
View file @
c448901d
...
@@ -15,11 +15,9 @@
...
@@ -15,11 +15,9 @@
<tr>
<tr>
<td>
{{ loan.book.title }}
</td>
<td>
{{ loan.book.title }}
</td>
<td>
{{ loan.member.user.username }}
</td>
<td>
{{ loan.member.user.username }}
</td>
{% if loan.remaining_loan_time %}
<td>
<td>
{{ loan.
remaining_loan_time.days }} days
left
{{ loan.
due_date|timeuntil:now }}
left
</td>
</td>
{% endif %}
<td>
{{ loan.loan_date }}
</td>
<td>
{{ loan.loan_date }}
</td>
<td>
{{ loan.due_date }}
</td>
<td>
{{ loan.due_date }}
</td>
<td>
{{ loan.return_date }}
</td>
<td>
{{ loan.return_date }}
</td>
...
...
loans/views.py
View file @
c448901d
...
@@ -32,6 +32,11 @@ class BookLoanListView(generic.ListView):
...
@@ -32,6 +32,11 @@ class BookLoanListView(generic.ListView):
return
queryset
.
order_by
(
"-created_at"
)
return
queryset
.
order_by
(
"-created_at"
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
"now"
]
=
timezone
.
now
()
return
context
class
BookLoanCreateView
(
generic
.
edit
.
CreateView
):
class
BookLoanCreateView
(
generic
.
edit
.
CreateView
):
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