Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvaalvarez_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
Angelo Alvarez
alvaalvarez_reading
Commits
047f310b
Commit
047f310b
authored
Apr 25, 2023
by
Angelo Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new Features: Edit Book and Edit Authors
parent
9287decf
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
79 additions
and
22 deletions
+79
-22
urls.cpython-310.pyc
...lvarez_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...varez_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
add-author.html
...rez_reading/bookshelf/templates/bookshelf/add-author.html
+1
-4
add-book.html
...varez_reading/bookshelf/templates/bookshelf/add-book.html
+1
-4
author_detail.html
..._reading/bookshelf/templates/bookshelf/author_detail.html
+15
-5
books_detail.html
...z_reading/bookshelf/templates/bookshelf/books_detail.html
+8
-1
edit-author.html
...ez_reading/bookshelf/templates/bookshelf/edit-author.html
+13
-0
edit-book.html
...arez_reading/bookshelf/templates/bookshelf/edit-book.html
+13
-0
home.html
alvaalvarez_reading/bookshelf/templates/bookshelf/home.html
+2
-2
urls.py
alvaalvarez_reading/bookshelf/urls.py
+3
-1
views.py
alvaalvarez_reading/bookshelf/views.py
+13
-5
style.css
alvaalvarez_reading/static/style.css
+10
-0
No files found.
alvaalvarez_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
047f310b
No preview for this file type
alvaalvarez_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
047f310b
No preview for this file type
alvaalvarez_reading/bookshelf/templates/bookshelf/add
_
author.html
→
alvaalvarez_reading/bookshelf/templates/bookshelf/add
-
author.html
View file @
047f310b
...
...
@@ -6,10 +6,7 @@
<form
method=
"POST"
>
{% csrf_token %}
{% for field in form %}
{{field.label}}: {{ field }}
<span
class=
"spacer"
></span>
{% endfor %}
{{ form.as_p }}
<button
type=
"Submit"
>
Add Author
</button>
</form>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/add
_
book.html
→
alvaalvarez_reading/bookshelf/templates/bookshelf/add
-
book.html
View file @
047f310b
...
...
@@ -6,10 +6,7 @@
<form
method=
"POST"
>
{% csrf_token %}
{% for field in form %}
{{field.label}}: {{ field }}
<span
class=
"spacer"
></span>
{% endfor %}
{{ form.as_p }}
<button
type=
"Submit"
>
Add Book
</button>
</form>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/author_detail.html
View file @
047f310b
...
...
@@ -7,18 +7,28 @@
<b>
Age:
</b>
{{ object.age }}
<br>
<b>
Nationality:
</b>
{{ object.nationality }}
<br>
{{ object.bio }}
<span
class=
"spacer"
></span>
<div
id=
"links"
>
<form
action=
"../edit"
>
<button
type=
"Submit"
>
Edit Author
</button>
</form>
</div>
<hr>
Books by {{ object.first_name }} {{ object.last_name }} I love:
<ul>
{% for book in
books
%}
{% if book.author.first_name == object.first_name and book.author.last_name == object.last_name %}
<
li><a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a></li
>
{% endif %}
{% for book in
object.books_set.all
%}
<li>
<
a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a
>
</li>
{% endfor %}
</ul>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<hr>
<div
id=
"links"
>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/books_detail.html
View file @
047f310b
...
...
@@ -9,9 +9,16 @@
<b>
Year published:
</b>
{{ object.year_published }}
<br>
<b>
ISBN:
</b>
{{ object.ISBN }}
<br>
{{ object.blurb }}
<div
id=
"links"
>
<form
action=
"../edit"
>
<button
type=
"Submit"
>
Edit Book
</button>
</form>
</div>
<hr>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<div
id=
"links"
>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
047f310b
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Author {% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"Submit"
>
Save Changes
</button>
</form>
{% endblock %}
\ No newline at end of file
alvaalvarez_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
047f310b
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"Submit"
>
Save Changes
</button>
</form>
{% endblock %}
\ No newline at end of file
alvaalvarez_reading/bookshelf/templates/bookshelf/home.html
View file @
047f310b
...
...
@@ -26,12 +26,12 @@ works of classic literature as I progress through my college career.
<hr>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<div
id=
"links"
>
<a
href=
"../books/"
>
Books
</a>
<a
href=
"../authors/"
>
Authors
</a>
</div>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<div
id=
"links"
>
<a
href=
"../books/add"
>
Add Book
</a>
<a
href=
"../authors/add"
>
Add Author
</a>
...
...
alvaalvarez_reading/bookshelf/urls.py
View file @
047f310b
from
django.urls
import
path
from
.views
import
home
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
,
BooksCreateView
,
AuthorCreateView
from
.views
import
home
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
,
BooksCreateView
,
AuthorCreateView
,
BooksUpdateView
,
AuthorUpdateView
urlpatterns
=
[
...
...
@@ -9,11 +9,13 @@ urlpatterns = [
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-details'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit/'
,
BooksUpdateView
.
as_view
(),
name
=
'edit-book'
),
#Authors
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-details'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:pk>/edit/'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
)
]
# This might be needed, depending on your Django version
...
...
alvaalvarez_reading/bookshelf/views.py
View file @
047f310b
...
...
@@ -2,7 +2,7 @@ from django.shortcuts import render
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Books
,
Author
# Create your views here.
...
...
@@ -21,7 +21,12 @@ class BooksDetailView(DetailView):
model
=
Books
class
BooksCreateView
(
CreateView
):
template_name
=
'bookshelf/add_book.html'
template_name
=
'bookshelf/add-book.html'
model
=
Books
fields
=
'__all__'
class
BooksUpdateView
(
UpdateView
):
template_name
=
'bookshelf/edit-book.html'
model
=
Books
fields
=
'__all__'
...
...
@@ -34,10 +39,13 @@ class AuthorListView(ListView):
class
AuthorDetailView
(
DetailView
):
template_name
=
'bookshelf/author_detail.html'
model
=
Author
booklist
=
Books
.
objects
.
all
()
extra_context
=
{
'books'
:
booklist
}
class
AuthorCreateView
(
CreateView
):
template_name
=
'bookshelf/add_author.html'
template_name
=
'bookshelf/add-author.html'
model
=
Author
fields
=
'__all__'
class
AuthorUpdateView
(
UpdateView
):
template_name
=
'bookshelf/edit-author.html'
model
=
Author
fields
=
'__all__'
\ No newline at end of file
alvaalvarez_reading/static/style.css
View file @
047f310b
...
...
@@ -41,4 +41,14 @@ ul li {
.spacer
{
display
:
block
;
margin-bottom
:
0.5em
;
}
#links
{
margin
:
auto
;
text-align
:
center
;
width
:
auto
;
}
button
{
margin
:
10px
;
}
\ 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