Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tanyayotoko_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
Tanya Yotoko
tanyayotoko_reading
Commits
fb2b132c
Commit
fb2b132c
authored
Mar 30, 2023
by
Tanya Yotoko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added template views and urls of app bookshelf, added CSS styling via bootstrap
parent
9c88de86
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
149 additions
and
7 deletions
+149
-7
models.py
tanyayotoko_reading/bookshelf/models.py
+10
-3
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+27
-0
authors.html
...yotoko_reading/bookshelf/templates/bookshelf/authors.html
+19
-0
book_details.html
...o_reading/bookshelf/templates/bookshelf/book_details.html
+18
-0
books.html
tanyayotoko_reading/bookshelf/templates/bookshelf/books.html
+18
-0
home.html
tanyayotoko_reading/bookshelf/templates/bookshelf/home.html
+12
-0
urls.py
tanyayotoko_reading/bookshelf/urls.py
+6
-2
views.py
tanyayotoko_reading/bookshelf/views.py
+25
-1
settings.py
tanyayotoko_reading/tanyayotoko_reading/settings.py
+1
-1
base.html
tanyayotoko_reading/templates/base.html
+13
-0
No files found.
tanyayotoko_reading/bookshelf/models.py
View file @
fb2b132c
from
django.db
import
models
from
django.db
import
models
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
,
MinLengthValidator
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
,
MinLengthValidator
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
first_name
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
...
@@ -9,11 +10,14 @@ class Author(models.Model):
...
@@ -9,11 +10,14 @@ class Author(models.Model):
bio
=
models
.
TextField
(
max_length
=
700
,
default
=
""
)
bio
=
models
.
TextField
(
max_length
=
700
,
default
=
""
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
first_name
,
self
.
last_name
)
return
'{} {}'
.
format
(
self
.
first_name
,
self
.
last_name
)
def
get_absolute_url
(
self
):
return
reverse
(
"bookshelf:author_details"
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Book
(
models
.
Model
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
title
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
,
related_name
=
'books'
)
publisher
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
publisher
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
year_published
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
2023
)])
year_published
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
2023
)])
ISBN
=
models
.
PositiveIntegerField
(
unique
=
True
,
validators
=
[
MaxValueValidator
(
9999999999999
),
MinValueValidator
(
1000000000000
)])
ISBN
=
models
.
PositiveIntegerField
(
unique
=
True
,
validators
=
[
MaxValueValidator
(
9999999999999
),
MinValueValidator
(
1000000000000
)])
...
@@ -21,3 +25,6 @@ class Book(models.Model):
...
@@ -21,3 +25,6 @@ class Book(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}'
.
format
(
self
.
title
,
self
.
author
)
return
'{}'
.
format
(
self
.
title
,
self
.
author
)
def
get_absolute_url
(
self
):
return
reverse
(
"bookshelf:book_details"
,
kwargs
=
{
'pk'
:
self
.
pk
})
\ No newline at end of file
tanyayotoko_reading/bookshelf/templates/bookshelf/author_details.html
0 → 100644
View file @
fb2b132c
{% extends 'base.html' %}
{% block title %}{{object.first_name}} {{object.last_name}}{% endblock %}
{% block content %}
<ul>
<li>
<h2>
{{object.first_name}} {{object.last_name}}
</h2>
</li>
<li>
<h4>
{{object.age}}
</h4>
</li>
<li>
<h4>
{{object.nationality}}
</h4>
</li>
<li>
<h4>
{{object.bio}}
</h4>
</li>
<li>
<h4>
Books by {{object.first_name}} {{object.last_name}} I love:
</h4>
</li>
<ul>
{% for book in object.books.all %}
<li>
<a
href=
"{{ book.get_absolute_url }}"
>
{{book.title}}
</a>
</li>
{% endfor %}
</ul>
<h2>
<a
href =
"/bookshelf/home/"
class=
"btn btn-primary"
role=
"button"
>
Home
</a>
<a
href =
"/bookshelf/books/"
class=
"btn btn-primary"
role=
"button"
>
Books
</a>
<a
href =
"/bookshelf/authors/"
class=
"btn btn-primary"
role=
"button"
>
Author
</a>
</h2>
</ul>
{% endblock %}
\ No newline at end of file
tanyayotoko_reading/bookshelf/templates/bookshelf/authors.html
0 → 100644
View file @
fb2b132c
{% extends 'base.html' %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h2>
Tanya's Favorite Authors:
</h2>
<ul
class=
"list-group"
>
{% for object in object_list %}
<li
class=
"list-group-item"
>
<a
href=
"{{ object.get_absolute_url }}"
>
{{object.first_name}} {{object.last_name}}
</a>
</li>
{% endfor %}
<h2>
<a
href =
"/bookshelf/home/"
class=
"btn btn-primary"
role=
"button"
>
Home
</a>
<a
href =
"/bookshelf/books/"
class=
"btn btn-primary"
role=
"button"
>
Books
</a>
</h2>
</ul>
{% endblock %}
\ No newline at end of file
tanyayotoko_reading/bookshelf/templates/bookshelf/book_details.html
0 → 100644
View file @
fb2b132c
{% extends 'base.html' %}
{% block title %}{{object.title}}{% endblock %}
{% block content %}
<ul>
<li>
<h3>
{{object.title}}
</h3>
</li>
<li>
<a
href =
"{{ object.author.get_absolute_url }}"
>
<h4>
{{object.author}}
</h4>
</a>
</li>
<li>
<h4>
{{object.publisher}}
</h4>
</li>
<li>
<h4>
{{object.year_published}}
</h4>
</li>
<li>
<h4>
{{object.ISBN}}
</h4>
</li>
<li>
<h4>
{{object.blurb}}
</h4>
</li>
<a
href =
"/bookshelf/home/"
class=
"btn btn-primary"
role=
"button"
>
Home
</a>
<a
href =
"/bookshelf/books/"
class=
"btn btn-primary"
role=
"button"
>
Books
</a>
<a
href =
"/bookshelf/authors/"
class=
"btn btn-primary"
role=
"button"
>
Authors
</a>
</ul>
{% endblock %}
\ No newline at end of file
tanyayotoko_reading/bookshelf/templates/bookshelf/books.html
0 → 100644
View file @
fb2b132c
{% extends 'base.html' %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h2>
Tanya's Favorite Books
</h2>
<ul
class=
"list-group"
>
{% for object in object_list %}
<li
class=
"list-group-item"
>
<a
href=
"{{ object.get_absolute_url }}"
>
{{object.title}}
</a>
</li>
{% endfor %}
<h3>
<a
href=
"/bookshelf/home/"
class=
"btn btn-primary"
role=
"button"
>
Home
</a>
<a
href=
"/bookshelf/authors"
class=
"btn btn-primary"
role=
"button"
>
Authors
</a>
</h3>
</ul>
{% endblock %}
\ No newline at end of file
tanyayotoko_reading/bookshelf/templates/bookshelf/home.html
0 → 100644
View file @
fb2b132c
{% extends 'base.html' %}
{% block title %}My Favorite Books
&
Authors{% endblock %}
{% block content %}
<h1
class=
"text-primary"
>
Welcome to Tanya's Database of Favorite Books and Authors
</h1>
<br>
<h4>
I am a mood reader and I like to explore genres when I have the time!
</h4>
<br>
<a
href=
"/bookshelf/books/"
class=
"btn btn-primary"
role=
"button"
>
Books
</a>
<a
href=
"/bookshelf/authors/"
class=
"btn btn-primary"
role=
"button"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
tanyayotoko_reading/bookshelf/urls.py
View file @
fb2b132c
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
,
homepage
,
BooksView
,
AuthorsView
,
BooksDetailView
,
AuthorsDetailView
from
.views
import
index
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'home/'
,
homepage
,
name
=
'home'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'authors'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'book_details'
),
path
(
'authors/<int:pk>/details/'
,
AuthorsDetailView
.
as_view
(),
name
=
'author_details'
),
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
\ No newline at end of file
tanyayotoko_reading/bookshelf/views.py
View file @
fb2b132c
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
.models
import
Author
,
Book
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
'Hello! This came from the index view'
)
return
HttpResponse
(
'Hello! This came from the index view'
)
def
homepage
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'homepage'
})
class
BooksView
(
ListView
):
model
=
Book
template_name
=
"bookshelf/books.html"
class
BooksDetailView
(
DetailView
):
model
=
Book
template_name
=
"bookshelf/book_details.html"
class
AuthorsView
(
ListView
):
model
=
Author
template_name
=
"bookshelf/authors.html"
class
AuthorsDetailView
(
DetailView
):
model
=
Author
template_name
=
"bookshelf/author_details.html"
tanyayotoko_reading/tanyayotoko_reading/settings.py
View file @
fb2b132c
...
@@ -58,7 +58,7 @@ ROOT_URLCONF = 'tanyayotoko_reading.urls'
...
@@ -58,7 +58,7 @@ ROOT_URLCONF = 'tanyayotoko_reading.urls'
TEMPLATES
=
[
TEMPLATES
=
[
{
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)
],
'APP_DIRS'
:
True
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'OPTIONS'
:
{
'context_processors'
:
[
'context_processors'
:
[
...
...
tanyayotoko_reading/templates/base.html
0 → 100644
View file @
fb2b132c
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width="
device-width
",
initial-scale=
1.0"
>
<title>
{% block title %}{% endblock %}
</title>
<link
rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
\ 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