Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
garethcastillo_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
Gareth Xerxes Yap Castillo
garethcastillo_reading
Commits
d51d23a6
Commit
d51d23a6
authored
Mar 28, 2023
by
Gareth Xerxes Yap Castillo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete html
parent
53fd3492
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
101 additions
and
7 deletions
+101
-7
urls.cpython-39.pyc
...astillo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...stillo_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+28
-0
authors.html
...stillo_reading/bookshelf/templates/bookshelf/authors.html
+9
-1
book_details.html
...o_reading/bookshelf/templates/bookshelf/book_details.html
+21
-0
books.html
...castillo_reading/bookshelf/templates/bookshelf/books.html
+9
-1
home.html
...hcastillo_reading/bookshelf/templates/bookshelf/home.html
+7
-1
urls.py
garethcastillo_reading/bookshelf/urls.py
+2
-2
views.py
garethcastillo_reading/bookshelf/views.py
+25
-2
No files found.
garethcastillo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
d51d23a6
No preview for this file type
garethcastillo_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
d51d23a6
No preview for this file type
garethcastillo_reading/bookshelf/templates/bookshelf/author_details.html
View file @
d51d23a6
{% extends 'base.html' %}
{% load static %}
{% block title %}{{author.first_name}} {{author.last_name}}{% endblock %}
{% block content %}
<h1>
{{author.first_name}} {{author.last_name}}
</h1>
<p>
{{author.age}}
<br
/>
{{author.nationality}}
<br
/>
{{author.bio}}
<br
/>
Books by {{author.first_name}} {{author.last_name}} I love:
<ol>
{% for object in books %}
<li><a
href =
"../../../books/{{object.pk}}/details/"
>
{{ object.title }}
</a></li>
{% empty %}
<li>
No books registered.
</li>
{% endfor %}
</ol>
<br
/>
<br
/>
<br
/>
<a
href =
"../../../home/"
>
Home
</a>
<a
href =
"../../../books/"
>
Books
</a>
<a
href =
"../../../authors/"
>
Authors
</a>
</p>
{% endblock %}
\ No newline at end of file
garethcastillo_reading/bookshelf/templates/bookshelf/authors.html
View file @
d51d23a6
...
@@ -7,9 +7,17 @@
...
@@ -7,9 +7,17 @@
<h1>
Gareth's Favorite Authors:
</h1>
<h1>
Gareth's Favorite Authors:
</h1>
<ol>
<ol>
{% for object in object_list %}
{% for object in object_list %}
<li><a
href =
"
authors/{{ object.id }}/details/"
>
{{ object.first_name }},
{{ object.last_name }}
</a></li>
<li><a
href =
"
{{ object.id }}/details/"
>
{{ object.first_name }}
{{ object.last_name }}
</a></li>
{% empty %}
{% empty %}
<li>
No books registered.
</li>
<li>
No books registered.
</li>
{% endfor %}
{% endfor %}
</ol>
</ol>
<p>
<br
/>
<br
/>
<br
/>
<a
href =
"../home/"
>
Home
</a>
<a
href =
"../books/"
>
Books
</a>
</p>
{% endblock %}
{% endblock %}
\ No newline at end of file
garethcastillo_reading/bookshelf/templates/bookshelf/book_details.html
View file @
d51d23a6
{% extends 'base.html' %}
{% load static %}
{% block title %}{{book.title}}{% endblock %}
{% block content %}
<h1>
{{book.title}}
</h1>
<p>
<a
href =
"../../../authors/{{book.author.pk}}/details/"
>
{{book.author.first_name}} {{book.author.last_name}}
</a>
<br
/>
{{book.publisher}}
<br
/>
{{book.year_published}}
<br
/>
{{book.isbn}}
<br
/>
{{book.blurb}}
<br
/>
<br
/>
<br
/>
<br
/>
<a
href =
"../../../home/"
>
Home
</a>
<a
href =
"../../../books/"
>
Books
</a>
<a
href =
"../../../authors/"
>
Authors
</a>
</p>
{% endblock %}
\ No newline at end of file
garethcastillo_reading/bookshelf/templates/bookshelf/books.html
View file @
d51d23a6
...
@@ -7,9 +7,17 @@
...
@@ -7,9 +7,17 @@
<h1>
Gareth's Favorite Books:
</h1>
<h1>
Gareth's Favorite Books:
</h1>
<ol>
<ol>
{% for object in object_list %}
{% for object in object_list %}
<li><a
href =
"
books/
{{ object.id }}/details/"
>
{{ object.title }}
</a></li>
<li><a
href =
"{{ object.id }}/details/"
>
{{ object.title }}
</a></li>
{% empty %}
{% empty %}
<li>
No books registered.
</li>
<li>
No books registered.
</li>
{% endfor %}
{% endfor %}
</ol>
</ol>
<p>
<br
/>
<br
/>
<br
/>
<a
href =
"../home/"
>
Home
</a>
<a
href =
"../authors/"
>
Authors
</a>
</p>
{% endblock %}
{% endblock %}
\ No newline at end of file
garethcastillo_reading/bookshelf/templates/bookshelf/home.html
View file @
d51d23a6
...
@@ -5,5 +5,11 @@
...
@@ -5,5 +5,11 @@
{% block content %}
{% block content %}
<h1>
Welcome to Gareth's Database of Favorite Books and Authors!
</h1>
<h1>
Welcome to Gareth's Database of Favorite Books and Authors!
</h1>
<p>
I enjoy a variety of genres, no specific one, as long as it is good.
</p>
<p>
I enjoy a variety of genres, no specific one, as long as it is good.
<br
/>
<br
/>
<br
/>
<a
href =
"../books/"
>
Books
</a>
<a
href =
"../authors/"
>
Authors
</a>
</p>
{% endblock %}
{% endblock %}
\ No newline at end of file
garethcastillo_reading/bookshelf/urls.py
View file @
d51d23a6
...
@@ -5,8 +5,8 @@ urlpatterns = [
...
@@ -5,8 +5,8 @@ urlpatterns = [
path
(
'home/'
,
views
.
homepage_view
,
name
=
'home'
),
path
(
'home/'
,
views
.
homepage_view
,
name
=
'home'
),
path
(
'books/'
,
views
.
book_view
.
as_view
(),
name
=
'books'
),
path
(
'books/'
,
views
.
book_view
.
as_view
(),
name
=
'books'
),
path
(
'authors/'
,
views
.
author_view
.
as_view
(),
name
=
'authors'
),
path
(
'authors/'
,
views
.
author_view
.
as_view
(),
name
=
'authors'
),
#path('book_details/', views.homepage_view, name='home
'),
path
(
'books/<int:book_id>/details/'
,
views
.
bookdetails_view
.
as_view
(),
name
=
'book_details
'
),
#path('author_details/', views.homepage_view, name='home
'),
path
(
'authors/<int:author_id>/details/'
,
views
.
authordetails_view
.
as_view
(),
name
=
'author_details
'
),
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
\ No newline at end of file
garethcastillo_reading/bookshelf/views.py
View file @
d51d23a6
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views
import
View
from
django.views
import
View
from
.models
import
Author
,
Books
from
.models
import
Author
,
Books
...
@@ -14,4 +14,27 @@ class book_view(View):
...
@@ -14,4 +14,27 @@ class book_view(View):
class
author_view
(
View
):
class
author_view
(
View
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
name
=
Author
.
objects
.
order_by
(
"first_name"
)
name
=
Author
.
objects
.
order_by
(
"first_name"
)
return
render
(
request
,
'bookshelf/authors.html'
,
{
'object_list'
:
name
})
return
render
(
request
,
'bookshelf/authors.html'
,
{
'object_list'
:
name
})
\ No newline at end of file
class
bookdetails_view
(
View
):
def
get
(
self
,
request
,
book_id
):
try
:
book
=
Books
.
objects
.
get
(
pk
=
book_id
)
except
Books
.
DoesNotExist
:
raise
Http404
(
"Book Does Not Exist"
)
displaybook
=
Books
.
objects
.
get
(
pk
=
book_id
)
return
render
(
request
,
'bookshelf/book_details.html'
,
{
'book'
:
displaybook
})
class
authordetails_view
(
View
):
def
get
(
self
,
request
,
author_id
):
try
:
author
=
Author
.
objects
.
get
(
pk
=
author_id
)
except
Author
.
DoesNotExist
:
raise
Http404
(
"Author Does Not Exist"
)
displayauthor
=
Author
.
objects
.
get
(
pk
=
author_id
)
books
=
Books
.
objects
.
filter
(
author
=
displayauthor
)
context
=
{
"author"
:
displayauthor
,
"books"
:
books
}
return
render
(
request
,
'bookshelf/author_details.html'
,
context
)
\ No newline at end of file
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