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
25dbefd5
Commit
25dbefd5
authored
Jul 09, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: upcoming loans and overdue loans page
parent
47b23a36
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
7 deletions
+88
-7
book_loan_table_data.html
book_loans/templates/book_loan_table_data.html
+1
-1
layout.html
dashboards/templates/layout.html
+14
-4
urls.py
dashboards/urls.py
+3
-1
views.py
dashboards/views.py
+70
-1
No files found.
book_loans/templates/book_loan_table_data.html
View file @
25dbefd5
...
...
@@ -15,7 +15,7 @@
<tr>
<td>
{{ loan.book.title }}
</td>
<td>
{{ loan.member.name }}
</td>
<td>
{{ loan.librarian
s
.name }}
</td>
<td>
{{ loan.librarian.name }}
</td>
<td>
{{ loan.loan_date }}
</td>
<td>
{{ loan.due_date }}
</td>
<td>
{{ loan.return_date }}
</td>
...
...
dashboards/templates/layout.html
View file @
25dbefd5
...
...
@@ -12,7 +12,7 @@
<a
href=
"/dashboard"
class=
"btn {% if request.path == '/dashboard/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-
bar-chart-line-fill"
></i>
Reports
</a
><i
class=
"bi bi-
columns-gap"
></i>
Dashboard
</a
>
<a
href=
"/dashboard/books"
...
...
@@ -24,15 +24,25 @@
class=
"btn {% if request.path == '/dashboard/members/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-person-vcard"
></i>
Members
</a
>
<a
href=
"/dashboard/librarians"
class=
"btn {% if request.path == '/dashboard/librarians/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-person-fill-lock"
></i>
Librarian
</a
>
<a
href=
"/dashboard/book-loans"
class=
"btn {% if request.path == '/dashboard/book-loans/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-calendar-week"
></i>
Book Loans
</a
>
<a
href=
"/dashboard/librarians"
class=
"btn {% if request.path == '/dashboard/librarians/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-person-fill-lock"
></i>
Librarian
</a
href=
"/dashboard/upcoming-loans/"
class=
"btn {% if request.path == '/dashboard/upcoming-loans/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-calendar2-event"
></i>
Upcoming Loans
</a
>
<a
href=
"/dashboard/overdued-loans/"
class=
"btn {% if request.path == '/dashboard/overdued-loans/' %}btn-primary{% else %}btn-outline-primary border-white text-white{% endif %} text-start w-100"
><i
class=
"bi bi-calendar2-x"
></i>
Overdued Loans
</a
>
</div>
</div>
...
...
dashboards/urls.py
View file @
25dbefd5
from
django.urls
import
path
,
include
from
dashboards.views
import
index
from
dashboards.views
import
index
,
UpcomingLoanView
,
OverduedLoanView
urlpatterns
=
[
path
(
""
,
index
,
name
=
"dashboard"
),
...
...
@@ -7,4 +7,6 @@ urlpatterns = [
path
(
"members/"
,
include
(
"members.urls"
)),
path
(
"book-loans/"
,
include
(
"book_loans.urls"
)),
path
(
"librarians/"
,
include
(
"librarians.urls"
)),
path
(
"upcoming-loans/"
,
UpcomingLoanView
.
as_view
(),
name
=
"upcoming_loans"
),
path
(
"overdued-loans/"
,
OverduedLoanView
.
as_view
(),
name
=
"overdued_loans"
),
]
dashboards/views.py
View file @
25dbefd5
from
datetime
import
datetime
,
timedelta
from
django.db.models
import
Q
from
django.views.generic
import
ListView
from
django.shortcuts
import
render
from
datetime
import
datetime
,
timedelta
from
librarians.models
import
LoginHistory
from
members.models
import
Members
from
book_loans.models
import
Book
,
BookLoans
class
OverduedLoanView
(
ListView
):
model
=
BookLoans
template_name
=
"loans.html"
paginate_by
=
5
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
keyword
=
self
.
request
.
GET
.
get
(
"q"
)
order
=
self
.
request
.
GET
.
get
(
"o"
)
now
=
datetime
.
now
()
queryset
=
queryset
.
filter
(
due_date__lte
=
now
,
return_date
=
None
)
.
order_by
(
"-updated_at"
)
if
keyword
:
queryset
=
queryset
.
filter
(
Q
(
book__title__icontains
=
keyword
)
|
Q
(
member__name__icontains
=
keyword
)
|
Q
(
librarian__name__icontains
=
keyword
)
)
.
order_by
(
"-created_at"
)
if
order
:
if
order
==
"new"
:
queryset
=
queryset
.
order_by
(
"-created_at"
)
elif
order
==
"old"
:
queryset
=
queryset
.
order_by
(
"created_at"
)
return
queryset
class
UpcomingLoanView
(
ListView
):
model
=
BookLoans
template_name
=
"loans.html"
paginate_by
=
5
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
keyword
=
self
.
request
.
GET
.
get
(
"q"
)
order
=
self
.
request
.
GET
.
get
(
"o"
)
now
=
datetime
.
now
()
due_date_treshold
=
now
.
today
()
+
timedelta
(
days
=
3
)
queryset
=
(
queryset
.
filter
(
due_date__lte
=
due_date_treshold
,
return_date
=
None
)
.
filter
(
due_date__gte
=
now
.
today
())
.
order_by
(
"-updated_at"
)
)
if
keyword
:
queryset
=
queryset
.
filter
(
Q
(
book__title__icontains
=
keyword
)
|
Q
(
member__name__icontains
=
keyword
)
|
Q
(
librarian__name__icontains
=
keyword
)
)
.
order_by
(
"-created_at"
)
if
order
:
if
order
==
"new"
:
queryset
=
queryset
.
order_by
(
"-created_at"
)
elif
order
==
"old"
:
queryset
=
queryset
.
order_by
(
"created_at"
)
return
queryset
def
home
(
request
):
return
render
(
request
,
"homepage.html"
)
...
...
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