Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
joaqscrisologo_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
Joaquin Inigo Crisologo
joaqscrisologo_reading
Commits
3f1bf76d
Commit
3f1bf76d
authored
Apr 25, 2023
by
Joaquin Inigo Crisologo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add UpdateViews for updating authors and books
parent
19ac7735
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
2 deletions
+65
-2
urls.cpython-39.pyc
...isologo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...sologo_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
edit-author.html
...go_reading/bookshelf/templates/bookshelf/edit-author.html
+25
-0
edit-book.html
...logo_reading/bookshelf/templates/bookshelf/edit-book.html
+25
-0
urls.py
joaqscrisologo_reading/bookshelf/urls.py
+5
-2
views.py
joaqscrisologo_reading/bookshelf/views.py
+10
-0
db.sqlite3
joaqscrisologo_reading/db.sqlite3
+0
-0
No files found.
joaqscrisologo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
3f1bf76d
No preview for this file type
joaqscrisologo_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
3f1bf76d
No preview for this file type
joaqscrisologo_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
3f1bf76d
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Author {% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<br>
<input
type=
"submit"
value=
"Save Changes"
>
</form>
<br><hr>
{% endblock %}
\ No newline at end of file
joaqscrisologo_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
3f1bf76d
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<br>
<input
type=
"submit"
value=
"Save Changes"
>
</form>
<br><hr>
{% endblock %}
\ No newline at end of file
joaqscrisologo_reading/bookshelf/urls.py
View file @
3f1bf76d
from
django.urls
import
path
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
,
AuthorCreateView
,
BooksCreateView
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
,
AuthorCreateView
,
BooksCreateView
,
AuthorUpdateView
,
BooksUpdateView
urlpatterns
=
[
path
(
''
,
HomeView
,
name
=
'index'
),
...
...
@@ -7,8 +7,11 @@ urlpatterns = [
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'authors/add'
,
AuthorCreateView
.
as_view
(),
name
=
'author-add'
),
path
(
'books/add'
,
BooksCreateView
.
as_view
(),
name
=
'book-add'
),
path
(
'books/add'
,
BooksCreateView
.
as_view
(),
name
=
'books-add'
),
path
(
'authors/<int:pk>/edit'
,
AuthorUpdateView
.
as_view
(),
name
=
'author-edit'
),
path
(
'books/<int:pk>/edit'
,
BooksUpdateView
.
as_view
(),
name
=
'books-edit'
),
]
# This might be needed, depending on your Django version
...
...
joaqscrisologo_reading/bookshelf/views.py
View file @
3f1bf76d
...
...
@@ -31,3 +31,13 @@ class BooksCreateView(CreateView):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
AuthorUpdateView
(
UpdateView
):
model
=
Author
fields
=
[
"first_name"
,
"last_name"
,
"age"
,
"nationality"
,
"bio"
]
template_name
=
'bookshelf/edit-author.html'
class
BooksUpdateView
(
UpdateView
):
model
=
Books
fields
=
[
"title"
,
"author"
,
"publisher"
,
"year_published"
,
"ISBN"
,
"blurb"
]
template_name
=
'bookshelf/edit-book.html'
joaqscrisologo_reading/db.sqlite3
View file @
3f1bf76d
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