Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
colleengarcia_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
Ann Colleen Garcia
colleengarcia_reading
Commits
b01f17f2
Commit
b01f17f2
authored
Apr 27, 2023
by
Colleen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the edit templates, views and urls
parent
753b82be
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
109 additions
and
4 deletions
+109
-4
models.cpython-39.pyc
bookshelf/__pycache__/models.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
edit-author.html
bookshelf/templates/bookshelf/edit-author.html
+23
-0
edit-book.html
bookshelf/templates/bookshelf/edit-book.html
+24
-0
home.html
bookshelf/templates/bookshelf/home.html
+12
-0
urls.py
bookshelf/urls.py
+6
-3
views.py
bookshelf/views.py
+44
-1
db.sqlite3
db.sqlite3
+0
-0
No files found.
bookshelf/__pycache__/models.cpython-39.pyc
View file @
b01f17f2
No preview for this file type
bookshelf/__pycache__/urls.cpython-39.pyc
View file @
b01f17f2
No preview for this file type
bookshelf/__pycache__/views.cpython-39.pyc
View file @
b01f17f2
No preview for this file type
bookshelf/templates/bookshelf/edit-author.html
View file @
b01f17f2
{% 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
action=
"/add_author"
method=
"post"
>
{% csrf_token %}
{{ form }}
First Name:
<input
type=
"text"
name=
"title"
/><br>
Last Name:
<input
type=
"text"
name=
"author"
/><br>
Age:
<input
type=
"text"
name=
"publisher"
/><br>
Nationality:
<input
type=
"text"
name=
"year_published"
/><br>
Bio:
<input
type=
"text"
name=
"ISBN"
/><p>
<input
type=
"submit"
value=
"Save Changes"
/>
</form>
{% endblock %}
\ No newline at end of file
bookshelf/templates/bookshelf/edit-book.html
View file @
b01f17f2
{% 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
action=
"/add_book"
method=
"post"
>
{% csrf_token %}
{{ form }}
Title:
<input
type=
"text"
name=
"title"
/><br>
Author:
<input
type=
"text"
name=
"author"
/><br>
Publisher:
<input
type=
"text"
name=
"publisher"
/><br>
Year Published:
<input
type=
"text"
name=
"year_published"
/><br>
ISBN:
<input
type=
"text"
name=
"ISBN"
/><br>
Blurb:
<input
type=
"text"
name=
"blurb"
/><br>
<input
type=
"submit"
value=
"Save Changes"
/>
</form>
{% endblock %}
\ No newline at end of file
bookshelf/templates/bookshelf/home.html
View file @
b01f17f2
...
...
@@ -12,10 +12,22 @@
</a>
</li>
</ul>
<ul>
<li>
<a
href=
"/bookshelf/books/add"
>
add books
</a>
</li>
</ul>
<ul>
<li>
<a
href=
"/bookshelf/authors"
>
authors
</a>
</li>
</ul>
<ul>
<li>
<a
href=
"/bookshelf/author/add"
>
add authors
</a>
</li>
</ul>
{% endblock %}
\ No newline at end of file
bookshelf/urls.py
View file @
b01f17f2
from
django.urls
import
path
from
.views
import
HomepageView
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
from
.views
import
HomepageView
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
,
AuthorUpdateView
,
Book_view
,
Author_view
urlpatterns
=
[
path
(
''
,
HomepageView
,
name
=
'homeview'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/add/'
,
Book_view
,
name
=
'books-add'
),
path
(
'books/<int:pk>'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'authors'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-detail'
),
path
(
'author'
,
AuthorListView
.
as_view
(),
name
=
'author-list'
),
path
(
'author/<int:pk>'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'author/add'
,
Author_view
,
name
=
'author-add'
),
path
(
'author/<int:pk>'
,
AuthorUpdateView
.
as_view
(),
name
=
'author-update'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
bookshelf/views.py
View file @
b01f17f2
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.shortcuts
import
render
,
redirect
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.shortcuts
import
render
from
.models
import
Author
,
Books
from
.forms
import
BooksForm
,
AuthorForm
def
HomepageView
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'Ian'
})
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'Colleen'
})
def
Book_view
(
request
):
if
request
.
method
==
'POST'
:
form
=
BooksForm
(
request
.
POST
)
if
form
.
is_valid
():
new_subject
=
form
.
save
()
return
redirect
(
'book_detail'
,
pk
=
new_subject
.
pk
)
else
:
form
=
BooksForm
()
return
render
(
request
,
'bookshelf/add-book.html'
,
{
'form'
:
form
})
def
Author_view
(
request
):
if
request
.
method
==
'POST'
:
form
=
AuthorForm
(
request
.
POST
)
if
form
.
is_valid
():
new_subject
=
form
.
save
()
return
redirect
(
'author_detail'
,
pk
=
new_subject
.
pk
)
else
:
form
=
AuthorForm
()
return
render
(
request
,
'bookshelf/add-author.html'
,
{
'form'
:
form
})
class
BooksListView
(
ListView
):
model
=
Books
...
...
@@ -20,3 +43,23 @@ class AuthorListView(ListView):
class
AuthorDetailView
(
DetailView
):
model
=
Author
class
BooksCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'add-book.html'
class
BooksUpdateView
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'edit-book.html'
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'add-author.html'
class
AuthorUpdateView
(
UpdateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'edit-author.html'
db.sqlite3
View file @
b01f17f2
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