Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
calvincruz_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
Calvin Josh Cruz
calvincruz_reading
Commits
7a199934
Commit
7a199934
authored
Mar 29, 2023
by
karin-kurusu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created "Books Page" and "Book's Details Page"
parent
64188981
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
3 deletions
+66
-3
models.cpython-310.pyc
...cruz_reading/bookshelf/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
...incruz_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...ncruz_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
models.py
calvincruz_reading/bookshelf/models.py
+5
-2
book_detais.html
...uz_reading/bookshelf/templates/bookshelf/book_detais.html
+24
-0
books.html
calvincruz_reading/bookshelf/templates/bookshelf/books.html
+21
-0
urls.py
calvincruz_reading/bookshelf/urls.py
+3
-1
views.py
calvincruz_reading/bookshelf/views.py
+13
-0
No files found.
calvincruz_reading/bookshelf/__pycache__/models.cpython-310.pyc
View file @
7a199934
No preview for this file type
calvincruz_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
7a199934
No preview for this file type
calvincruz_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
7a199934
No preview for this file type
calvincruz_reading/bookshelf/models.py
View file @
7a199934
from
django.db
import
models
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
250
,
default
=
""
)
...
...
@@ -17,8 +18,10 @@ class Books(models.Model):
year_published
=
models
.
PositiveIntegerField
(
null
=
True
,
default
=
""
)
ISBN
=
models
.
CharField
(
unique
=
True
,
null
=
True
,
max_length
=
13
,
default
=
""
)
blurb
=
models
.
TextField
()
def
__str__
(
self
):
return
"
\'
{}
\'
by {} {}"
.
format
(
self
.
title
,
self
.
author
.
first_name
,
self
.
author
.
last_name
)
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:book_detais'
,
args
=
[
self
.
pk
])
# Create your models here.
calvincruz_reading/bookshelf/templates/bookshelf/book_detais.html
0 → 100644
View file @
7a199934
{% extends 'base.html' %}
{% load static %}
{% block title %}{{book.title}}{% endblock %}
{% block content %}
<h2>
{{book.title}}
</h2>
<p>
{{author.first_name}} {{author.last_name}}
</p>
<p>
{{book.publisher}}
</p>
<p>
{{book.year_published}}
</p>
<p>
{{book.ISBN}}
</p>
<p>
{{book.blurb}}
</p>
{% endblock %}
{% block navbar %}
<ul
class=
"navbarList"
>
<li
class=
"navbarItem"
><a
href=
"/home"
>
Home
</a></li>
<li
class=
"navbarItem"
><a
href=
"/books"
>
Books
</a></li>
<li
class=
"navBarItem"
><a
href=
"/authors"
>
Authors
</a></li>
</ul>
{% endblock %}
\ No newline at end of file
calvincruz_reading/bookshelf/templates/bookshelf/books.html
0 → 100644
View file @
7a199934
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h2>
{{name}}'s Favorite Books:
</h2>
<ul>
{% for book in books_list %}
<li><a
href=
"{{book.get_absolute_url}}"
>
{{book.title}}
</a></li>
{% endfor %}
</ul>
{% endblock %}
{% block navbar %}
<ul
class=
"navbarList"
>
<li
class=
"navbarItem"
><a
href=
"/home"
>
Home
</a></li>
<li
class=
"navBarItem"
><a
href=
"/authors"
>
Authors
</a></li>
</ul>
{% endblock %}
\ No newline at end of file
calvincruz_reading/bookshelf/urls.py
View file @
7a199934
from
django.urls
import
path
from
.views
import
home
from
.views
import
home
,
BooksList
,
BooksDetails
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'books/'
,
BooksList
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BooksDetails
.
as_view
(),
name
=
'book_detais'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
calvincruz_reading/bookshelf/views.py
View file @
7a199934
from
django.shortcuts
import
render
from
django.views
import
View
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
.models
import
Author
,
Books
def
home
(
request
):
return
render
(
request
,
'home.html'
,
{
'name'
:
'Calvin'
})
class
BooksList
(
ListView
):
def
get
(
self
,
request
):
books_list
=
Books
.
objects
.
all
()
return
render
(
request
,
'bookshelf/books.html'
,
{
'name'
:
'Calvin'
,
'books_list'
:
books_list
})
class
BooksDetails
(
DetailView
):
def
get
(
self
,
request
,
pk
):
book
=
Books
.
objects
.
get
(
pk
=
pk
)
author
=
book
.
author
return
render
(
request
,
'bookshelf/book_detais.html'
,
{
'author'
:
author
,
'book'
:
book
})
# Create your views here.
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