Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
brevinque_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
Nate Brevin A. Que
brevinque_reading
Commits
454df46e
Commit
454df46e
authored
Apr 25, 2023
by
Nate Brevin A. Que
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lab04' into 'master'
Lab04 See merge request
!1
parents
2988fa92
c549c273
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
102 additions
and
12 deletions
+102
-12
add-author.html
...que_reading/bookshelf/templates/bookshelf/add-author.html
+13
-0
add-book.html
...inque_reading/bookshelf/templates/bookshelf/add-book.html
+13
-0
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+6
-5
book_details.html
...e_reading/bookshelf/templates/bookshelf/book_details.html
+4
-3
edit-author.html
...ue_reading/bookshelf/templates/bookshelf/edit-author.html
+13
-0
edit-book.html
...nque_reading/bookshelf/templates/bookshelf/edit-book.html
+13
-0
home.html
brevinque_reading/bookshelf/templates/bookshelf/home.html
+4
-2
urls.py
brevinque_reading/bookshelf/urls.py
+6
-1
views.py
brevinque_reading/bookshelf/views.py
+30
-1
db.sqlite3
brevinque_reading/db.sqlite3
+0
-0
No files found.
brevinque_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
454df46e
{% extends 'base.html' %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Author"
>
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
454df46e
{% extends 'base.html' %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/templates/bookshelf/author_details.html
View file @
454df46e
...
...
@@ -5,16 +5,17 @@
<h1>
{{ author }}
</h1>
<h3>
{{ author.age }}
<br>
{{ author.nationality }}
<br>
{{ author.bio }}
</h3><br>
{{ author.bio }}
</h3>
<a
href=
"/authors/{{ author.pk }}/edit"
><input
type=
"submit"
value=
"Edit Book"
></a><br>
<h3>
Books by {{ author }} I love:
</h3>
<ul>
{% for book in author.books_set.all %}
<li><a
href=
"
http://127.0.0.1:8000/
{{ book.get_absolute_url }}"
>
{{ book.title }}
</a></li>
<li><a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a></li>
{% endfor %}
</ul>
{% endblock %}
{% block scripts %}
<a
href=
"
http://127.0.0.1:8000
/home"
>
Home
</a>
<a
href=
"
http://127.0.0.1:8000
/books"
>
Books
</a>
<a
href=
"
http://127.0.0.1:8000
/authors"
>
Authors
</a>
<a
href=
"/home"
>
Home
</a>
<a
href=
"/books"
>
Books
</a>
<a
href=
"/authors"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/templates/bookshelf/book_details.html
View file @
454df46e
...
...
@@ -10,7 +10,8 @@
{{ book.blurb }}
</h3>
{% endblock %}
{% block scripts %}
<a
href=
"http://127.0.0.1:8000/home"
>
Home
</a>
<a
href=
"http://127.0.0.1:8000/books"
>
Books
</a>
<a
href=
"http://127.0.0.1:8000/authors"
>
Authors
</a>
<a
href=
"/books/{{ book.pk }}/edit"
><input
type=
"submit"
value=
"Edit Book"
></a><br>
<a
href=
"/home"
>
Home
</a>
<a
href=
"/books"
>
Books
</a>
<a
href=
"/authors"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
454df46e
{% extends 'base.html' %}
{% block title %}Edit Author{% endblock %}
{% block content %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
454df46e
{% extends 'base.html' %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/templates/bookshelf/home.html
View file @
454df46e
...
...
@@ -14,6 +14,8 @@
a kid, either through movies or school.
</h3><br><br>
{% endblock %}
{% block scripts %}
<a
href=
"http://127.0.0.1:8000/books"
>
Books
</a>
<a
href=
"http://127.0.0.1:8000/authors"
>
Authors
</a>
<a
href=
"/books"
>
Books
</a>
<a
href=
"/authors"
>
Authors
</a><br>
<a
href=
"/books/add"
>
Add Book
</a>
<a
href=
"/authors/add"
>
Add Author
</a>
{% endblock %}
\ No newline at end of file
brevinque_reading/bookshelf/urls.py
View file @
454df46e
from
django.urls
import
path
from
.views
import
homepage_view
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
from
.views
import
(
homepage_view
,
BooksListView
,
BooksDetailView
,
BooksCreateView
,
BooksUpdateView
,
AuthorListView
,
AuthorDetailView
,
AuthorCreateView
,
AuthorUpdateView
)
urlpatterns
=
[
path
(
'home/'
,
homepage_view
,
name
=
'home'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'book-details'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit'
,
BooksUpdateView
.
as_view
(),
name
=
'edit-book'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-details'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:pk>/edit'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
brevinque_reading/bookshelf/views.py
View file @
454df46e
from
django.shortcuts
import
render
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Books
,
Author
...
...
@@ -11,23 +12,51 @@ def homepage_view(request):
class
BooksListView
(
ListView
):
model
=
Books
def
get
(
self
,
request
):
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
"Brevin"
,
'books'
:
self
.
model
.
objects
.
all
()})
class
BooksDetailView
(
DetailView
):
model
=
Books
def
get
(
self
,
request
,
pk
):
return
render
(
request
,
'bookshelf/book_details.html'
,
{
'book'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
class
BooksCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
BooksUpdateView
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/edit-book.html'
class
AuthorListView
(
ListView
):
model
=
Author
def
get
(
self
,
request
):
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
"Brevin"
,
'authors'
:
self
.
model
.
objects
.
all
()})
class
AuthorDetailView
(
DetailView
):
model
=
Author
def
get
(
self
,
request
,
pk
):
return
render
(
request
,
'bookshelf/author_details.html'
,
{
'author'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
\ No newline at end of file
return
render
(
request
,
'bookshelf/author_details.html'
,
{
'author'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
class
AuthorUpdateView
(
UpdateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/edit-author.html'
\ No newline at end of file
brevinque_reading/db.sqlite3
View file @
454df46e
No preview for this file type
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