Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nishaespera_reading
Project
Project
Details
Activity
Releases
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
Julia Anishka
nishaespera_reading
Commits
f02679a0
Commit
f02679a0
authored
Mar 27, 2023
by
Julia Anishka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added bookslistview and booksdetailview pages
parent
30c8cf6b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
2 deletions
+47
-2
models.py
nishaespera_reading/bookshelf/models.py
+3
-0
book_detail.html
...ra_reading/bookshelf/templates/bookshelf/book_detail.html
+19
-0
books.html
nishaespera_reading/bookshelf/templates/bookshelf/books.html
+19
-0
urls.py
nishaespera_reading/bookshelf/urls.py
+3
-2
views.py
nishaespera_reading/bookshelf/views.py
+3
-0
No files found.
nishaespera_reading/bookshelf/models.py
View file @
f02679a0
...
@@ -15,6 +15,9 @@ class Author(models.Model):
...
@@ -15,6 +15,9 @@ class Author(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
first_name
+
' '
+
self
.
last_name
return
self
.
first_name
+
' '
+
self
.
last_name
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:author-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
verify_ISBN
(
value
):
def
verify_ISBN
(
value
):
if
value
.
isdigit
()
==
False
:
if
value
.
isdigit
()
==
False
:
raise
ValidationError
(
'ISBN must only be integers.'
)
raise
ValidationError
(
'ISBN must only be integers.'
)
...
...
nishaespera_reading/bookshelf/templates/bookshelf/book_detail.html
0 → 100644
View file @
f02679a0
# This page contains a detailed view of the information from the book.
{% extends 'base.html' %}
{% block title %} {{ book.title }} {% endblock %}
{% block body %}
<h2>
{{ book.title }}
</h2>
<h4>
<a
href=
"{{ author.get_absolute_url }}"
>
{{ book.author }}
</a>
</h4>
<h4>
{{ book.publisher }}
</h4>
<h4>
{{ book.year_published }}
</h4>
<h4>
{{ book.ISBN }}
</h4>
<h4>
{{ book.blurb }}
</h4>
<h5>
<a
href=
"{% url 'home' %}"
>
Home
</a>
<a
href=
"{% url 'books' %}"
>
Books
</a>
<a
href=
"{% url 'authors'}"
>
Authors
</a>
</h5>
{% endblock %}
\ No newline at end of file
nishaespera_reading/bookshelf/templates/bookshelf/books.html
View file @
f02679a0
# This page contains all books in a list view.
{% extends 'base.html' %}
{% block title %} My Favorite Books {% endblock %}
{% block content %}
<h3>
Nisha's Favorite Books
</h3>
<div>
<ul>
{% for book in books_list %}
<li>
<a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a>
</li>
{% endfor %}
</ul>
</div>
<h5>
<a
href=
"{% url 'home' %}"
>
Home
</a>
<a
href=
"{% url 'authors'}"
>
Authors
</a></h5>
{% endblock %}
\ No newline at end of file
nishaespera_reading/bookshelf/urls.py
View file @
f02679a0
from
django.urls
import
path
from
django.urls
import
path
from
.
import
views
from
.
import
views
from
.views
import
BooksListView
from
.views
import
BooksListView
,
BooksDetailView
urlpatterns
=
[
urlpatterns
=
[
path
(
'home'
,
views
.
homepage_view
,
name
=
'home'
),
path
(
'home'
,
views
.
homepage_view
,
name
=
'home'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
)
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
]
]
...
...
nishaespera_reading/bookshelf/views.py
View file @
f02679a0
...
@@ -17,3 +17,6 @@ def homepage_view(request):
...
@@ -17,3 +17,6 @@ def homepage_view(request):
class
BooksListView
(
ListView
):
class
BooksListView
(
ListView
):
model
=
Books
model
=
Books
class
BooksDetailView
(
DetailView
):
model
=
Books
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