Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rafa_mendoza_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
Rafa Mendoza
rafa_mendoza_reading
Commits
ae15e8ac
Commit
ae15e8ac
authored
Mar 29, 2023
by
Rafa Mendoza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added html pages
parent
fec011a4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
143 additions
and
11 deletions
+143
-11
models.py
bookshelf/models.py
+9
-11
author.html
bookshelf/templates/author.html
+19
-0
author_details.html
bookshelf/templates/author_details.html
+22
-0
books.html
bookshelf/templates/books.html
+21
-0
books_details.html
bookshelf/templates/books_details.html
+17
-0
home.html
bookshelf/templates/home.html
+13
-0
urls.py
bookshelf/urls.py
+14
-0
views.py
bookshelf/views.py
+28
-0
No files found.
bookshelf/models.py
View file @
ae15e8ac
from
django.db
import
models
# -- coding: UTF-8 --
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
...
...
@@ -10,14 +10,14 @@ class Author(models.Model):
bio
=
models
.
CharField
(
max_length
=
700
)
def
__str__
(
self
):
return
'''{}
, {}, {}, {},
{}'''
.
format
(
return
'''{} {}'''
.
format
(
self
.
first_name
,
self
.
last_name
,
self
.
age
,
self
.
nationality
,
self
.
bio
,
)
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:author_details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
125
)
...
...
@@ -28,11 +28,9 @@ class Books(models.Model):
blurb
=
models
.
TextField
()
def
__str__
(
self
):
return
'''{}
, {}, {}, {}, {}, {}
'''
.
format
(
return
'''{}'''
.
format
(
self
.
title
,
self
.
author
,
self
.
publisher
,
self
.
year_published
,
self
.
isbn
,
self
.
blurb
,
)
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:book_details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
bookshelf/templates/author.html
0 → 100644
View file @
ae15e8ac
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Authors{% endblock %}
{% block content %}
<h1>
Rafa's Favorite Authors:
</h1>
<ul>
{% for author in author_list %}
<li>
<a
href=
"{{author.get_absolute_url}}"
>
{{ author.first_name }} {{ author.last_name }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
{% block footer %}
<a
href=
"/home"
>
Home
</a>
--
<a
href=
"/books"
>
Books
</a>
{% endblock %}
\ No newline at end of file
bookshelf/templates/author_details.html
0 → 100644
View file @
ae15e8ac
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ author.first_name }} {{ author.last_name }} {% endblock %}
{% block content %}
<h1>
{{ author.first_name }} {{ author.last_name }}
</h1>
<h3>
{{ author.age }}
</h3>
<h3>
{{ author.nationality }}
</h3>
<h3>
{{ author.bio }}
</h3>
<br>
<h2>
Books by {{ author.first_name }} {{ author.last_name }} I love:
</h2>
<ul>
{% for book in author.books_set.all %}
<li>
<a
href=
"{{ books.get_absolute_url }}"
>
{{ book.title }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
{% block footer %}
<a
href=
"/home"
>
Home
</a>
--
<a
href=
"/books"
>
Books
</a>
--
<a
href=
"/author"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
bookshelf/templates/books.html
0 → 100644
View file @
ae15e8ac
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Books{% endblock %}
{% block content %}
<h1>
Rafa's Favorite Books:
</h1>
<ul>
{% for book in books_list %}
<li>
<a
href=
"{{ books.get_absolute_url}}"
>
{{ books.title }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}
{% block footer %}
<a
href=
"/home"
>
Home
</a>
--
<a
href=
"/author"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
bookshelf/templates/books_details.html
0 → 100644
View file @
ae15e8ac
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ books.title }} {% endblock %}
{% block content %}
<h1>
{{ books.title }}
</h1>
<h2><a
href=
"{{ books.author.get_absolute_url }}"
>
{{ books.author.first_name }} {{ books.author.last_name }}
</a></h2>
<h3>
{{ books.publisher }}
</h3>
<h3>
{{ books.year_published }}
</h3>
<h3>
{{ books.ISBN }}
</h3>
<p>
{{ books.blurb }}
</p>
{% endblock %}
{% block footer %}
<a
href=
"/home"
>
Home
</a>
--
<a
href=
"/books"
>
Books
</a>
--
<a
href=
"/author"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
bookshelf/templates/home.html
0 → 100644
View file @
ae15e8ac
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Books And Authors {% endblock %}
{% block content %}
<h2>
Welcome to Rafa's Database of Favorite Books and Authors!
</h2>
<br>
<p>
Not gonna lie, I don't really enjoy reading. Books makes me sleepy...
So, the books that I do enjoy are exceptionally good! Take my word for it.
</p>
{% endblock %}
{% block footer %}
<a
href=
"/books"
>
Books
</a>
--
<a
href=
"/author"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
bookshelf/urls.py
0 → 100644
View file @
ae15e8ac
from
django.urls
import
path
from
.views
import
(
BooksView
,
PerBooksView
,
AuthorView
,
PerAuthorView
,
)
urlpatterns
=
[
path
(
'books'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'books<int:pk>/details'
,
PerBooksView
.
as_view
(),
name
=
'book_details'
),
path
(
'author'
,
AuthorView
.
as_view
(),
name
=
'author'
),
path
(
'author<int:pk>/details'
,
PerAuthorView
.
as_view
(),
name
=
'author_details'
),
]
app_name
=
'bookshelf'
bookshelf/views.py
0 → 100644
View file @
ae15e8ac
from
django.shortcuts
import
render
from
.models
import
Author
,
Books
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
def
home
(
request
):
return
render
(
request
,
'bookshelf/home.html'
)
class
BooksView
(
ListView
):
model
=
Books
template_name
=
'books.html'
class
PerBooksView
(
DetailView
):
model
=
Books
template_name
=
'books_details.html'
class
AuthorView
(
ListView
):
model
=
Author
template_name
=
'author.html'
class
PerAuthorView
(
DetailView
):
model
=
Author
template_name
=
'author_details.html'
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