Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eldondagdag_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
Eldon Dagdag
eldondagdag_reading
Commits
bfcb336e
Commit
bfcb336e
authored
Mar 28, 2023
by
Eldon Dagdag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created pages for Home, Books, Authors, & Details
parent
ee782a7a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
155 additions
and
6 deletions
+155
-6
models.py
eldondagdag_reading/bookshelf/models.py
+7
-1
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+22
-0
authors.html
...dagdag_reading/bookshelf/templates/bookshelf/authors.html
+20
-0
book_details.html
...g_reading/bookshelf/templates/bookshelf/book_details.html
+19
-0
books.html
eldondagdag_reading/bookshelf/templates/bookshelf/books.html
+20
-0
home.html
eldondagdag_reading/bookshelf/templates/bookshelf/home.html
+10
-0
urls.py
eldondagdag_reading/bookshelf/urls.py
+7
-2
views.py
eldondagdag_reading/bookshelf/views.py
+33
-2
settings.py
eldondagdag_reading/eldondagdag_reading/settings.py
+1
-1
base.html
eldondagdag_reading/templates/base.html
+16
-0
No files found.
eldondagdag_reading/bookshelf/models.py
View file @
bfcb336e
from
django.db
import
models
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
...
...
@@ -10,10 +11,13 @@ class Author(models.Model):
def
__str__
(
self
):
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
):
title
=
models
.
CharField
(
max_length
=
255
,
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
=
255
,
default
=
''
)
year_published
=
models
.
PositiveIntegerField
()
ISBN
=
models
.
PositiveBigIntegerField
(
validators
=
[
MinValueValidator
(
1000000000000
),
MaxValueValidator
(
9999999999999
)])
...
...
@@ -22,3 +26,5 @@ class Book(models.Model):
def
__str__
(
self
):
return
'{} by {}'
.
format
(
self
.
title
,
self
.
author
)
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:book-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
eldondagdag_reading/bookshelf/templates/bookshelf/author_details.html
0 → 100644
View file @
bfcb336e
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }} {{ object.last_name }}{% endblock %}
{% block content %}
<html>
<h1>
{{ object.first_name }} {{ object.last_name }}
</h1>
<body>
<h3>
Age: {{ object.age }}
</h3>
<h3>
Nationality: {{ object.nationality }}
</h3>
<h3>
Biography: {{ object.bio }}
</h3>
<h2>
Books by {{ object.first_name }} {{ object.last_name }} I love:
</h2>
{% for book in object.books.all %}
<li><a
href=
{{
book
.
get_absolute_url
}}
>
{{ book.title }}
</a></li>
{% endfor %}
</body>
<br>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
</html>
{% endblock %}
\ No newline at end of file
eldondagdag_reading/bookshelf/templates/bookshelf/authors.html
0 → 100644
View file @
bfcb336e
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<html>
<h1>
Eldon's Favorite Authors:
</h1>
<body>
{% for object in object_list %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.first_name }} {{ object.last_name }}
</a>
</li>
{% endfor %}
</body>
<br>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
</html>
{% endblock %}
\ No newline at end of file
eldondagdag_reading/bookshelf/templates/bookshelf/book_details.html
0 → 100644
View file @
bfcb336e
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.title }}{% endblock %}
{% block content %}
<html>
<body>
<h1>
{{ object.title }}
</h1>
<h2>
by
<a
href=
"{{ object.author.get_absolute_url }}"
>
{{ object.author }}
</a></h2>
<h3>
Published by {{ object.publisher }}
</h3>
<h3>
Published in {{ object.year_published }}
</h3>
<h3>
ISBN: {{ object.ISBN }}
</h3>
<h3>
"{{ object.blurb }}"
</h3>
</body>
<br>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
</html>
{% endblock %}
\ No newline at end of file
eldondagdag_reading/bookshelf/templates/bookshelf/books.html
0 → 100644
View file @
bfcb336e
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<html>
<h1>
Eldon's Favorite Books:
</h1>
<body>
{% for object in object_list %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.title }}
</a>
</li>
{% endfor %}
</body>
<br>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
</html>
{% endblock %}
\ No newline at end of file
eldondagdag_reading/bookshelf/templates/bookshelf/home.html
0 → 100644
View file @
bfcb336e
{% extends 'base.html' %}
{% load static %}
{% block title %}My Favorite Books
&
Authors{% endblock %}
{% block content %}
<h1>
Welcome to Eldon's Database of Favorite Books and Authors!
</h1>
<h3>
Vibes only here.
</h3>
<br>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
eldondagdag_reading/bookshelf/urls.py
View file @
bfcb336e
from
django.urls
import
path
from
.views
import
index
from
.views
import
index
_view
,
home
,
BookListView
,
BookDetailView
,
AuthorListView
,
AuthorDetailView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
)
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'books/'
,
BookListView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details/'
,
BookDetailView
.
as_view
(),
name
=
'book-details'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-details'
),
path
(
''
,
index_view
,
name
=
'index'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
eldondagdag_reading/bookshelf/views.py
View file @
bfcb336e
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic
import
ListView
,
DetailView
def
index
(
request
):
return
HttpResponse
(
'Hello World!'
)
\ No newline at end of file
from
.models
import
Author
,
Book
def
index_view
(
request
):
return
HttpResponse
(
"yes"
)
def
home
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'home'
})
class
BookListView
(
ListView
):
model
=
Book
template_name
=
'bookshelf/books.html'
class
BookDetailView
(
DetailView
):
model
=
Book
template_name
=
'bookshelf/book_details.html'
class
AuthorListView
(
ListView
):
model
=
Author
template_name
=
'bookshelf/authors.html'
class
AuthorDetailView
(
DetailView
):
model
=
Author
template_name
=
'bookshelf/author_details.html'
# def index_view(request):
# return render(request, 'home.html', {'name': 'home'})
# class HomepageView(View):
# def get(self, request):
# return render(request, 'home.html', {'name': 'home'})
\ No newline at end of file
eldondagdag_reading/eldondagdag_reading/settings.py
View file @
bfcb336e
...
...
@@ -59,7 +59,7 @@ ROOT_URLCONF = 'eldondagdag_reading.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[],
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)
],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
...
...
eldondagdag_reading/templates/base.html
0 → 100644
View file @
bfcb336e
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width-device-width,initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"style.css"
>
<title>
{% block title %}{% endblock %}
</title>
{% block styles %}{% endblock %}
</head>
<body>
<div
id=
"content"
>
{% block content %}{% endblock %}
</div>
{% block scripts %}{% 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