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
Show 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 @@
...
@@ -6,10 +6,7 @@
<form
method=
"POST"
>
<form
method=
"POST"
>
{% csrf_token %}
{% csrf_token %}
{% for field in form %}
{{ form.as_p }}
{{field.label}}: {{ field }}
<span
class=
"spacer"
></span>
{% endfor %}
<button
type=
"Submit"
>
Add Author
</button>
<button
type=
"Submit"
>
Add Author
</button>
</form>
</form>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/add
_
book.html
→
alvaalvarez_reading/bookshelf/templates/bookshelf/add
-
book.html
View file @
047f310b
...
@@ -6,10 +6,7 @@
...
@@ -6,10 +6,7 @@
<form
method=
"POST"
>
<form
method=
"POST"
>
{% csrf_token %}
{% csrf_token %}
{% for field in form %}
{{ form.as_p }}
{{field.label}}: {{ field }}
<span
class=
"spacer"
></span>
{% endfor %}
<button
type=
"Submit"
>
Add Book
</button>
<button
type=
"Submit"
>
Add Book
</button>
</form>
</form>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/author_detail.html
View file @
047f310b
...
@@ -7,18 +7,28 @@
...
@@ -7,18 +7,28 @@
<b>
Age:
</b>
{{ object.age }}
<br>
<b>
Age:
</b>
{{ object.age }}
<br>
<b>
Nationality:
</b>
{{ object.nationality }}
<br>
<b>
Nationality:
</b>
{{ object.nationality }}
<br>
{{ object.bio }}
{{ object.bio }}
<span
class=
"spacer"
></span>
<div
id=
"links"
>
<form
action=
"../edit"
>
<button
type=
"Submit"
>
Edit Author
</button>
</form>
</div>
<hr>
<hr>
Books by {{ object.first_name }} {{ object.last_name }} I love:
Books by {{ object.first_name }} {{ object.last_name }} I love:
<ul>
<ul>
{% for book in
books
%}
{% for book in
object.books_set.all
%}
{% if book.author.first_name == object.first_name and book.author.last_name == object.last_name %}
<li>
<
li><a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a></li
>
<
a
href=
"{{ book.get_absolute_url }}"
>
{{ book.title }}
</a
>
{% endif %}
</li>
{% endfor %}
{% endfor %}
</ul>
</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/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
...
...
alvaalvarez_reading/bookshelf/templates/bookshelf/books_detail.html
View file @
047f310b
...
@@ -9,9 +9,16 @@
...
@@ -9,9 +9,16 @@
<b>
Year published:
</b>
{{ object.year_published }}
<br>
<b>
Year published:
</b>
{{ object.year_published }}
<br>
<b>
ISBN:
</b>
{{ object.ISBN }}
<br>
<b>
ISBN:
</b>
{{ object.ISBN }}
<br>
{{ object.blurb }}
{{ object.blurb }}
<div
id=
"links"
>
<form
action=
"../edit"
>
<button
type=
"Submit"
>
Edit Book
</button>
</form>
</div>
<hr>
<hr>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<div
id=
"links"
>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/home/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</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.
...
@@ -26,12 +26,12 @@ works of classic literature as I progress through my college career.
<hr>
<hr>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<div
id=
"links"
>
<a
href=
"../books/"
>
Books
</a>
<a
href=
"../books/"
>
Books
</a>
<a
href=
"../authors/"
>
Authors
</a>
<a
href=
"../authors/"
>
Authors
</a>
</div>
</div>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<div
id=
"links"
>
<a
href=
"../books/add"
>
Add Book
</a>
<a
href=
"../books/add"
>
Add Book
</a>
<a
href=
"../authors/add"
>
Add Author
</a>
<a
href=
"../authors/add"
>
Add Author
</a>
...
...
alvaalvarez_reading/bookshelf/urls.py
View file @
047f310b
from
django.urls
import
path
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
=
[
urlpatterns
=
[
...
@@ -9,11 +9,13 @@ urlpatterns = [
...
@@ -9,11 +9,13 @@ urlpatterns = [
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-details'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-details'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit/'
,
BooksUpdateView
.
as_view
(),
name
=
'edit-book'
),
#Authors
#Authors
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-details'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-details'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
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
# 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
...
@@ -2,7 +2,7 @@ from django.shortcuts import render
from
django.views
import
View
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
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
from
.models
import
Books
,
Author
# Create your views here.
# Create your views here.
...
@@ -21,7 +21,12 @@ class BooksDetailView(DetailView):
...
@@ -21,7 +21,12 @@ class BooksDetailView(DetailView):
model
=
Books
model
=
Books
class
BooksCreateView
(
CreateView
):
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
model
=
Books
fields
=
'__all__'
fields
=
'__all__'
...
@@ -34,10 +39,13 @@ class AuthorListView(ListView):
...
@@ -34,10 +39,13 @@ class AuthorListView(ListView):
class
AuthorDetailView
(
DetailView
):
class
AuthorDetailView
(
DetailView
):
template_name
=
'bookshelf/author_detail.html'
template_name
=
'bookshelf/author_detail.html'
model
=
Author
model
=
Author
booklist
=
Books
.
objects
.
all
()
extra_context
=
{
'books'
:
booklist
}
class
AuthorCreateView
(
CreateView
):
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
model
=
Author
fields
=
'__all__'
fields
=
'__all__'
\ No newline at end of file
alvaalvarez_reading/static/style.css
View file @
047f310b
...
@@ -42,3 +42,13 @@ ul li {
...
@@ -42,3 +42,13 @@ ul li {
display
:
block
;
display
:
block
;
margin-bottom
:
0.5em
;
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