Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gabgeraldo_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
Gabriel Geraldo
gabgeraldo_reading
Commits
6b9af395
Commit
6b9af395
authored
Apr 25, 2023
by
Gabriel Geraldo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented add and edit book features
parent
60700b3e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
3 deletions
+55
-3
add-book.html
...raldo_reading/bookshelf/templates/bookshelf/add-book.html
+18
-0
book_details.html
...o_reading/bookshelf/templates/bookshelf/book_details.html
+3
-1
edit-book.html
...aldo_reading/bookshelf/templates/bookshelf/edit-book.html
+18
-0
urls.py
gabgeraldo_reading/bookshelf/urls.py
+3
-1
views.py
gabgeraldo_reading/bookshelf/views.py
+12
-0
base.html
gabgeraldo_reading/templates/base.html
+1
-1
No files found.
gabgeraldo_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
6b9af395
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Book {% endblock %}
{% block style %}
<link
rel=
'stylesheet'
type=
'text/css'
href=
"{% static 'base.css' %}"
/>
{% endblock %}
{% block content %}
<header>
Add New Book
</header>
<section>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
</section>
{% endblock %}
\ No newline at end of file
gabgeraldo_reading/bookshelf/templates/bookshelf/book_details.html
View file @
6b9af395
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
<li
class=
"subinfo"
>
Year Published: {{ object.year_published}}
</li>
<li
class=
"subinfo"
>
Year Published: {{ object.year_published}}
</li>
<li
class=
"subinfo"
>
ISBN: {{ object.isbn }}
</li>
<li
class=
"subinfo"
>
ISBN: {{ object.isbn }}
</li>
<li
class=
"subinfo"
>
Short Description:
<br>
{{ object.blurb }}
</li>
<li
class=
"subinfo"
>
Short Description:
<br>
{{ object.blurb }}
</li>
<form
action=
"edit"
>
<input
type=
"submit"
value=
"Edit Book"
/>
</form>
</ul>
</ul>
</section>
</section>
<nav>
<nav>
...
@@ -31,5 +34,4 @@
...
@@ -31,5 +34,4 @@
<a
class=
"primary-link"
href=
"../../authors"
>
Authors
</a>
<a
class=
"primary-link"
href=
"../../authors"
>
Authors
</a>
</div>
</div>
</nav>
</nav>
{% endblock %}
{% endblock %}
gabgeraldo_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
6b9af395
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block style %}
<link
rel=
'stylesheet'
type=
'text/css'
href=
"{% static 'base.css' %}"
/>
{% endblock %}
{% block content %}
<header>
Edit Book
</header>
<section>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
</section>
{% endblock %}
\ No newline at end of file
gabgeraldo_reading/bookshelf/urls.py
View file @
6b9af395
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index_view
,
home_view
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
from
.views
import
index_view
,
home_view
,
BooksListView
,
BooksDetailView
,
BooksCreateView
,
BooksUpdateView
,
AuthorListView
,
AuthorDetailView
urlpatterns
=
[
urlpatterns
=
[
...
@@ -7,6 +7,8 @@ urlpatterns = [
...
@@ -7,6 +7,8 @@ urlpatterns = [
path
(
'home/'
,
home_view
,
name
=
'home'
),
path
(
'home/'
,
home_view
,
name
=
'home'
),
path
(
'books/'
,
BooksListView
.
as_view
(
template_name
=
'bookshelf/books.html'
),
name
=
'books'
),
path
(
'books/'
,
BooksListView
.
as_view
(
template_name
=
'bookshelf/books.html'
),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(
template_name
=
'bookshelf/book_details.html'
),
name
=
'book_details'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(
template_name
=
'bookshelf/book_details.html'
),
name
=
'book_details'
),
path
(
'books/add'
,
BooksCreateView
.
as_view
(),
name
=
'books_add'
),
path
(
'books/<int:pk>/edit'
,
BooksUpdateView
.
as_view
(),
name
=
"books_edit"
),
path
(
'authors/'
,
AuthorListView
.
as_view
(
template_name
=
'bookshelf/authors.html'
),
name
=
'authors'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(
template_name
=
'bookshelf/authors.html'
),
name
=
'authors'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(
template_name
=
'bookshelf/author_details.html'
),
name
=
'author_details'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(
template_name
=
'bookshelf/author_details.html'
),
name
=
'author_details'
),
]
]
...
...
gabgeraldo_reading/bookshelf/views.py
View file @
6b9af395
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views
import
View
from
django.views
import
View
from
django.views.generic.edit
import
CreateView
,
UpdateView
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
...
@@ -23,6 +24,17 @@ class BooksListView(ListView):
...
@@ -23,6 +24,17 @@ class BooksListView(ListView):
class
BooksDetailView
(
DetailView
):
class
BooksDetailView
(
DetailView
):
model
=
Books
model
=
Books
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
):
class
AuthorListView
(
ListView
):
model
=
Author
model
=
Author
...
...
gabgeraldo_reading/templates/base.html
View file @
6b9af395
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>
{% block title %}
My amazing site
{% endblock %}
</title>
<title>
{% block title %}{% endblock %}
</title>
{% block style %}{% endblock %}
{% block style %}{% endblock %}
{% block scripts %} {% endblock %}
{% block scripts %} {% endblock %}
</head>
</head>
...
...
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