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
f5e47d8a
Commit
f5e47d8a
authored
Jul 10, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: book detail
parent
0bde8217
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
17 deletions
+57
-17
book_detail.html
books/templates/book_detail.html
+36
-0
book_table_data.html
books/templates/book_table_data.html
+5
-14
urls.py
books/urls.py
+10
-3
views.py
books/views.py
+6
-0
No files found.
books/templates/book_detail.html
0 → 100644
View file @
f5e47d8a
{% extends "layout.html" %} {% block dashboard %}
<div
style=
"max-width: 80vw"
class=
"w-100 p-4"
>
<div
class=
"d-flex justify-content-between pb-4"
>
<div
class=
"d-flex gap-2 pb-4"
>
<a
class=
"btn btn-success"
href=
"/dashboard/books/{{ book.id }}/update"
>
<i
class=
"bi bi-pencil-square"
></i>
Edit
</a>
<a
class=
"btn btn-danger"
href=
"/dashboard/books/{{ book.id }}/delete/"
>
<i
class=
"bi bi-trash3-fill"
></i>
Delete
</a>
</div>
</div>
{% if book.cover_image %}
<div
class=
"d-flex gap-5"
>
<img
class=
"object-fit-contain"
height=
"360"
src=
"{{ book.cover_image.url }}"
alt=
"{{ book.title }}"
/>
<div
class=
"col"
>
<h1
class=
"h2 row"
>
{{ book.title }}
</h1>
<p
class=
"h5 row"
>
{{ book.description }}
</p>
<p
class=
"h5 row"
>
Stock: {{ book.stock }}
</p>
<p
class=
"row badge text-bg-secondary"
>
{{ book.category.name }}
</p>
<time
datetime=
"{{ book.created_at }}"
class=
"row fs-6"
>
Created at: {{ book.created_at }}
</time
>
<time
datetime=
"{{ book.updated_at }}"
class=
"row fs-6"
>
Updated at: {{ book.updated_at }}
</time
>
</div>
</div>
{% endif %}
</div>
{% endblock dashboard %}
books/templates/book_table_data.html
View file @
f5e47d8a
<table
class=
"table table-hover"
>
<table
class=
"table table-hover"
>
<thead>
<thead>
<tr
class=
"table-primary"
>
<tr
class=
"table-primary"
>
<th
scope=
"col"
>
Cover
</th>
<th
scope=
"col"
>
Title
</th>
<th
scope=
"col"
>
Title
</th>
<th
scope=
"col"
>
Category
</th>
<th
scope=
"col"
>
Category
</th>
<th
scope=
"col"
>
Stock
</th>
<th
scope=
"col"
>
Stock
</th>
...
@@ -14,17 +13,7 @@
...
@@ -14,17 +13,7 @@
<tbody>
<tbody>
{% if object_list %} {% for book in object_list %}
{% if object_list %} {% for book in object_list %}
<tr>
<tr>
<td>
<td><a
href=
"/dashboard/books/{{ book.id }}/"
>
{{ book.title }}
</a></td>
{% if book.cover_image %}
<img
style=
"object-fit: contain"
width=
"100"
height=
"100"
src=
"{{ book.cover_image.url }}"
/>
{% endif %}
</td>
<td>
{{ book.title }}
</td>
<td>
{{ book.category.name }}
</td>
<td>
{{ book.category.name }}
</td>
<td>
{{ book.stock }}
</td>
<td>
{{ book.stock }}
</td>
<td>
{{ book.description }}
</td>
<td>
{{ book.description }}
</td>
...
@@ -32,7 +21,10 @@
...
@@ -32,7 +21,10 @@
<td>
{{ book.updated_at }}
</td>
<td>
{{ book.updated_at }}
</td>
<td>
<td>
<div
class=
"d-flex gap-2"
>
<div
class=
"d-flex gap-2"
>
<a
class=
"btn btn-success"
href=
"/dashboard/books/{{ book.id }}/"
>
<a
class=
"btn btn-success"
href=
"/dashboard/books/{{ book.id }}/update"
>
<i
class=
"bi bi-pencil-square"
></i>
<i
class=
"bi bi-pencil-square"
></i>
</a>
</a>
<a
<a
...
@@ -55,7 +47,6 @@
...
@@ -55,7 +47,6 @@
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tr>
{% endif %}
{% endif %}
</tbody>
</tbody>
...
...
books/urls.py
View file @
f5e47d8a
from
django.urls
import
path
from
django.urls
import
path
from
books.views
import
BookListView
,
BookCreateView
,
BookUpdateView
,
BookDeleteView
from
books.views
import
(
BookListView
,
BookDetailView
,
BookCreateView
,
BookUpdateView
,
BookDeleteView
,
)
urlpatterns
=
[
urlpatterns
=
[
path
(
""
,
BookListView
.
as_view
(),
name
=
"book_list"
),
path
(
""
,
BookListView
.
as_view
(),
name
=
"book_list"
),
path
(
"add/"
,
BookCreateView
.
as_view
(),
name
=
"book_update"
),
path
(
"add/"
,
BookCreateView
.
as_view
(),
name
=
"book_add"
),
path
(
"<int:pk>/"
,
BookUpdateView
.
as_view
(),
name
=
"book_update"
),
path
(
"<int:pk>/"
,
BookDetailView
.
as_view
(),
name
=
"book_detail"
),
path
(
"<int:pk>/update/"
,
BookUpdateView
.
as_view
(),
name
=
"book_update"
),
path
(
"<int:pk>/delete/"
,
BookDeleteView
.
as_view
(),
name
=
"book_delete"
),
path
(
"<int:pk>/delete/"
,
BookDeleteView
.
as_view
(),
name
=
"book_delete"
),
]
]
books/views.py
View file @
f5e47d8a
...
@@ -30,6 +30,12 @@ class BookListView(generic.ListView):
...
@@ -30,6 +30,12 @@ class BookListView(generic.ListView):
return
queryset
.
order_by
(
"-updated_at"
)
return
queryset
.
order_by
(
"-updated_at"
)
class
BookDetailView
(
generic
.
DeleteView
):
model
=
Book
template_name
=
"book_detail.html"
context_object_name
=
"book"
class
BookCreateView
(
generic
.
edit
.
CreateView
):
class
BookCreateView
(
generic
.
edit
.
CreateView
):
model
=
Book
model
=
Book
form_class
=
BookForm
form_class
=
BookForm
...
...
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