Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Deokhyun_Lee_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
Deokhyun Lee
Deokhyun_Lee_reading
Commits
295a0ad7
Commit
295a0ad7
authored
Apr 25, 2023
by
Deokhyun Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added addbook html and view is attached.
parent
ce62230b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
3 deletions
+51
-3
forms.py
Deokhyun_Lee_reading/bookshelf/forms.py
+10
-0
add-book.html
Deokhyun_Lee_reading/bookshelf/templates/books/add-book.html
+11
-0
books.html
Deokhyun_Lee_reading/bookshelf/templates/books/books.html
+2
-0
home.html
Deokhyun_Lee_reading/bookshelf/templates/home/home.html
+4
-1
urls.py
Deokhyun_Lee_reading/bookshelf/urls.py
+2
-1
views.py
Deokhyun_Lee_reading/bookshelf/views.py
+19
-1
styles.css
Deokhyun_Lee_reading/templates/styles.css
+3
-0
No files found.
Deokhyun_Lee_reading/bookshelf/forms.py
0 → 100644
View file @
295a0ad7
from
django
import
forms
from
.models
import
Author
class
AddBookForm
(
forms
.
Form
):
title
=
forms
.
CharField
(
max_length
=
100
)
author
=
forms
.
ModelChoiceField
(
queryset
=
Author
.
objects
.
all
())
publisher
=
forms
.
CharField
(
max_length
=
100
)
year_published
=
forms
.
DateTimeField
()
ISBN
=
forms
.
CharField
(
max_length
=
13
)
blurb
=
forms
.
CharField
(
max_length
=
250
)
Deokhyun_Lee_reading/bookshelf/templates/books/add-book.html
0 → 100644
View file @
295a0ad7
{% extends 'base.html'%}
{% block title %}
Add New Book
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Add Book
</button>
</form>
{% endblock %}
\ No newline at end of file
Deokhyun_Lee_reading/bookshelf/templates/books/books.html
View file @
295a0ad7
...
@@ -15,5 +15,7 @@
...
@@ -15,5 +15,7 @@
{% else %}
{% else %}
<p>
No Available Books.
</p>
<p>
No Available Books.
</p>
{% endif %}
{% endif %}
<a
href=
"/home"
>
Home
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors"
>
Authors
</a>
<a
href=
"/home"
>
Home
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors"
>
Authors
</a>
{% endblock %}
{% endblock %}
\ No newline at end of file
Deokhyun_Lee_reading/bookshelf/templates/home/home.html
View file @
295a0ad7
...
@@ -11,5 +11,8 @@
...
@@ -11,5 +11,8 @@
Therefore, Frank Herbert's
Therefore, Frank Herbert's
Dune is one of the best
Dune is one of the best
American authors for me!
</p></p>
American authors for me!
</p></p>
<a
href=
"/books"
>
Books
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors"
>
Authors
</a>
<ul>
<li><a
href=
"/books"
>
Books
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors"
>
Authors
</a></li>
<li><a
href=
"/books/add"
>
Add Book
</a>
&
nbsp
&
nbsp
&
nbsp
&
nbsp
&
nbsp
<a
href=
"/authors/add"
>
Add Author
</a></li>
</ul>
{% endblock %}
{% endblock %}
\ No newline at end of file
Deokhyun_Lee_reading/bookshelf/urls.py
View file @
295a0ad7
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BookListView
,
BookDetailView
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BookListView
,
BookDetailView
,
BookAddListView
urlpatterns
=
[
urlpatterns
=
[
# for Home (landing page)
# for Home (landing page)
...
@@ -10,4 +10,5 @@ urlpatterns = [
...
@@ -10,4 +10,5 @@ urlpatterns = [
# for Books page
# for Books page
path
(
'books/'
,
BookListView
.
as_view
(),
name
=
'books'
),
path
(
'books/'
,
BookListView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BookDetailView
.
as_view
(),
name
=
'book-detail'
),
path
(
'books/<int:pk>/details'
,
BookDetailView
.
as_view
(),
name
=
'book-detail'
),
path
(
'books/add'
,
BookAddListView
.
as_view
(),
name
=
"add-book"
)
]
]
\ No newline at end of file
Deokhyun_Lee_reading/bookshelf/views.py
View file @
295a0ad7
...
@@ -2,6 +2,7 @@ from django.views import View
...
@@ -2,6 +2,7 @@ from django.views import View
from
django.views.generic
import
ListView
,
DetailView
from
django.views.generic
import
ListView
,
DetailView
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
.models
import
Author
,
Books
from
.models
import
Author
,
Books
from
.forms
import
AddBookForm
# View for Home (landing page)
# View for Home (landing page)
class
HomeView
(
View
):
class
HomeView
(
View
):
...
@@ -39,3 +40,20 @@ class BookDetailView(DetailView):
...
@@ -39,3 +40,20 @@ class BookDetailView(DetailView):
model
=
Books
model
=
Books
template_name
=
'books/book_details.html'
template_name
=
'books/book_details.html'
context_object_name
=
'book'
context_object_name
=
'book'
class
BookAddListView
(
ListView
):
template_name
=
'add-book.html'
form_class
=
AddBookForm
def
form_valid
(
self
,
form
):
# Create a new book object with the form data
new_book
=
Books
.
objects
.
create
(
title
=
form
.
cleaned_data
[
'title'
],
author
=
form
.
cleaned_data
[
'author'
],
publisher
=
form
.
cleaned_data
[
'publisher'
],
year_published
=
form
.
cleaned_data
[
'year_published'
],
ISBN
=
form
.
cleaned_data
[
'ISBN'
],
blurb
=
form
.
cleaned_data
[
'blurb'
]
)
# Redirect the user to the list of books
return
super
()
.
form_valid
(
form
)
Deokhyun_Lee_reading/templates/styles.css
View file @
295a0ad7
.row
{
grid-row
:
1
/
span
2
;
}
\ 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