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
74298e50
Commit
74298e50
authored
Jul 02, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: overdue book loan and near overdue book loan
parent
1ad162ef
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
3 deletions
+71
-3
index.html
dashboards/templates/dashboard/index.html
+6
-0
near_overdue_loan.html
dashboards/templates/dashboard/near_overdue_loan.html
+19
-0
overdue_loan.html
dashboards/templates/dashboard/overdue_loan.html
+17
-0
summary.html
dashboards/templates/dashboard/summary.html
+12
-2
views.py
dashboards/views.py
+17
-1
No files found.
dashboards/templates/dashboard/index.html
View file @
74298e50
...
...
@@ -2,6 +2,12 @@
<div
style=
"max-width: 80vw"
class=
"w-100 p-4"
>
<h1
class=
"h2"
>
Reports
</h1>
<div
class=
"row container pt-5"
>
{% include "dashboard/summary.html" %}
</div>
<div
class=
"row container pt-5"
>
{% include "dashboard/overdue_loan.html" %}
</div>
<div
class=
"row container pt-5"
>
{% include "dashboard/near_overdue_loan.html" %}
</div>
<div
class=
"row container pt-5"
>
{% include "dashboard/login_history.html" %}
</div>
...
...
dashboards/templates/dashboard/near_overdue_loan.html
0 → 100644
View file @
74298e50
<table
class=
"table"
>
<legend
class=
"h3"
>
Near Overdue Book Loan
</legend>
<thead>
<tr>
<th
scope=
"col"
>
Book Title
</th>
<th
scope=
"col"
>
Due Date
</th>
<th
scope=
"col"
>
Loan Date
</th>
</tr>
</thead>
<tbody>
{% for loan in near_overdue_loans %}
<tr>
<td>
{{ loan.book.title }}
</td>
<td>
{{ loan.due_date }}
</td>
<td>
{{ loan.loan_date }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
dashboards/templates/dashboard/overdue_loan.html
0 → 100644
View file @
74298e50
<table
class=
"table"
>
<legend
class=
"h3"
>
Overdue Book Loan
</legend>
<thead>
<tr>
<th
scope=
"col"
>
Book Title
</th>
<th
scope=
"col"
>
Due Date
</th>
</tr>
</thead>
<tbody>
{% for loan in overdue_loans %}
<tr>
<td>
{{ loan.book.title }}
</td>
<td>
{{ loan.due_date }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
dashboards/templates/dashboard/summary.html
View file @
74298e50
<h3
class=
"h3"
>
At a Glance
</h3>
<div
class=
"row container text-center"
>
<div
class=
"col"
>
<div
class=
"card h-100 d-flex flex-column"
>
...
...
@@ -31,9 +32,18 @@
<div
class=
"card h-100"
>
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
<i
class=
"bi bi-calendar-week"
></i>
Total
Book Loan
<i
class=
"bi bi-calendar-week"
></i>
Book Loan
</h5>
<p
class=
"h1"
>
{{ total_book_loans }}
</p>
<div
class=
"d-flex justify-content-center"
>
<div
class=
"card"
>
<div
class=
"card-header"
>
Total
</div>
<p
class=
"h1"
>
{{ total_book_loans }}
</p>
</div>
<div
class=
"card"
>
<div
class=
"card-header"
>
Overdue
</div>
<p
class=
"h1"
>
{{ total_overdue }}
</p>
</div>
</div>
</div>
<div
class=
"card-footer"
>
<a
href=
"/dashboard/book-loans/"
class=
"w-100 btn btn-primary"
...
...
dashboards/views.py
View file @
74298e50
from
datetime
import
datetime
,
timedelta
from
django.shortcuts
import
render
from
librarians.models
import
LoginHistory
from
members.models
import
Members
...
...
@@ -9,15 +10,30 @@ def home(request):
def
index
(
request
):
latest_login_history
=
LoginHistory
.
objects
.
order_by
(
"login_at"
)[:
10
]
latest_login_history
=
LoginHistory
.
objects
.
order_by
(
"
-
login_at"
)[:
10
]
total_book
=
Book
.
objects
.
count
()
total_member
=
Members
.
objects
.
count
()
total_book_loans
=
BookLoans
.
objects
.
count
()
now
=
datetime
.
now
()
overdue_loans
=
BookLoans
.
objects
.
filter
(
due_date__lte
=
now
)
for
loan
in
BookLoans
.
objects
.
all
():
near_overdue_window
=
loan
.
due_date
-
timedelta
(
days
=
7
)
due_date
=
loan
.
due_date
near_overdue_loans
=
BookLoans
.
objects
.
filter
(
due_date__range
=
(
near_overdue_window
,
due_date
)
)
context
=
{
"login_histories"
:
latest_login_history
,
"total_book"
:
total_book
,
"total_member"
:
total_member
,
"total_book_loans"
:
total_book_loans
,
"total_overdue"
:
overdue_loans
.
count
(),
"overdue_loans"
:
overdue_loans
,
"near_overdue_loans"
:
near_overdue_loans
,
}
return
render
(
request
,
"dashboard/index.html"
,
context
)
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