Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mavlee_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
Mavrick Jordan Lee
mavlee_reading
Commits
b8061ebf
Commit
b8061ebf
authored
Mar 28, 2023
by
Mavrick Jordan Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created views for author and author_details. Made necessary changes in other files.
parent
a566fc1e
Pipeline
#3062
canceled with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
11 deletions
+50
-11
models.py
mavlee_reading/bookshelf/models.py
+3
-0
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+23
-0
authors.html
mavlee_reading/bookshelf/templates/bookshelf/authors.html
+11
-2
book_details.html
...e_reading/bookshelf/templates/bookshelf/book_details.html
+1
-1
urls.py
mavlee_reading/bookshelf/urls.py
+4
-3
views.py
mavlee_reading/bookshelf/views.py
+8
-5
No files found.
mavlee_reading/bookshelf/models.py
View file @
b8061ebf
...
@@ -12,6 +12,9 @@ class Author(models.Model):
...
@@ -12,6 +12,9 @@ class Author(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
first_name
+
" "
+
self
.
last_name
return
self
.
first_name
+
" "
+
self
.
last_name
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:author-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Book
(
models
.
Model
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
)
title
=
models
.
CharField
(
max_length
=
50
)
...
...
mavlee_reading/bookshelf/templates/bookshelf/author_details.html
0 → 100644
View file @
b8061ebf
{% extends 'base.html' %}
{% block title %}{{ object.first_name }} {{ object.last_name }}{% endblock %}
{% block content %}
<h1>
{{ object.first_name }} {{ object.last_name }}
</h1>
<p>
{{ object.age }}
<br>
{{ object.nationality }}
<br>
{{ object.bio }}
<br>
Books by {{ object.first_name }} {{ object.last_name }} I love:
</p>
<ul>
{% for book in object.book_set.all %}
<li>
<a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a>
</li>
{% endfor %}
</ul>
<a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"{% url 'bookshelf:books' %}"
>
Books
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"{% url 'bookshelf:authors' %}"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
mavlee_reading/bookshelf/templates/bookshelf/authors.html
View file @
b8061ebf
{% extends 'base.html' %}
{% extends 'base.html' %}
{% block title %}My Favorite Authors{% endblock %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
{% block content %}
<h1>
{{name}}'s Favorite Authors:
</h1>
<h1>
Mav's Favorite Authors:
</h1>
<p>
Mav like Japanese manga with authors that writes in a serious tone.
</p>
<ul>
{% for object in object_list %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.first_name }} {{ object.last_name }}
</a>
</li>
{% endfor %}
</ul>
<a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"{% url 'bookshelf:books' %}"
>
Books
</a>
{% endblock %}
{% endblock %}
\ No newline at end of file
mavlee_reading/bookshelf/templates/bookshelf/book_details.html
View file @
b8061ebf
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
{% block content %}
{% block content %}
<h1>
{{ object.title }}
</h1>
<h1>
{{ object.title }}
</h1>
<p>
<p>
{{ object.author }}
<br>
<a
href=
"{{ object.author.get_absolute_url }}"
>
{{ object.author }}
</a>
<br>
{{ object.publisher }}
<br>
{{ object.publisher }}
<br>
{{ object.year_published }}
<br>
{{ object.year_published }}
<br>
{{ object.ISBN }}
<br>
{{ object.ISBN }}
<br>
...
...
mavlee_reading/bookshelf/urls.py
View file @
b8061ebf
from
django.urls
import
path
from
django.urls
import
path
from
.
import
views
from
.
import
views
from
.views
import
BooksListView
,
BookDetailsView
from
.views
import
BooksListView
,
BookDetailsView
,
AuthorsListView
,
AuthorDetailsView
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
views
.
home_view
,
name
=
"home"
),
path
(
'home/'
,
views
.
home_view
,
name
=
"home"
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
"books"
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
"books"
),
path
(
'books/<int:pk>/details'
,
BookDetailsView
.
as_view
(),
name
=
"book-detail"
),
path
(
'books/<int:pk>/details/'
,
BookDetailsView
.
as_view
(),
name
=
"book-detail"
),
path
(
'authors/'
,
views
.
authors_view
,
name
=
"authors"
),
path
(
'authors/'
,
AuthorsListView
.
as_view
(),
name
=
"authors"
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailsView
.
as_view
(),
name
=
"author-detail"
),
]
]
app_name
=
'bookshelf'
app_name
=
'bookshelf'
\ No newline at end of file
mavlee_reading/bookshelf/views.py
View file @
b8061ebf
...
@@ -9,11 +9,6 @@ from .models import Author, Book
...
@@ -9,11 +9,6 @@ from .models import Author, Book
def
home_view
(
request
):
def
home_view
(
request
):
return
render
(
request
,
'bookshelf/home.html'
)
return
render
(
request
,
'bookshelf/home.html'
)
def
authors_view
(
request
):
return
render
(
request
,
'bookshelf/authors.html'
,
{
'name'
:
'Mav'
,
})
class
BooksListView
(
ListView
):
class
BooksListView
(
ListView
):
model
=
Book
model
=
Book
template_name
=
'bookshelf/books.html'
template_name
=
'bookshelf/books.html'
...
@@ -21,3 +16,11 @@ class BooksListView(ListView):
...
@@ -21,3 +16,11 @@ class BooksListView(ListView):
class
BookDetailsView
(
DetailView
):
class
BookDetailsView
(
DetailView
):
model
=
Book
model
=
Book
template_name
=
'bookshelf/book_details.html'
template_name
=
'bookshelf/book_details.html'
class
AuthorsListView
(
ListView
):
model
=
Author
template_name
=
'bookshelf/authors.html'
class
AuthorDetailsView
(
DetailView
):
model
=
Author
template_name
=
'bookshelf/author_details.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