Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
janang_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
Jan Ericsson Ong Ang
janang_reading
Commits
e4cf8f0a
Commit
e4cf8f0a
authored
Apr 25, 2023
by
Jan Ericsson Ong Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created forms.py
parent
eb95db7f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
9 deletions
+45
-9
forms.py
janang_reading/bookshelf/forms.py
+16
-4
add-book.html
janang_reading/bookshelf/templates/bookshelf/add-book.html
+11
-5
views.py
janang_reading/bookshelf/views.py
+18
-0
No files found.
janang_reading/bookshelf/forms.py
View file @
e4cf8f0a
from
django
import
forms
from
django
import
forms
from
django.db
import
models
from
models
import
Author
class
IndexCardForm
(
forms
.
Form
):
class
AuthorForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
label
=
'Full Name'
,
max_length
=
100
)
first_name
=
forms
.
CharField
(
label
=
'first_name'
,
max_length
=
50
)
section
=
forms
.
CharField
(
label
=
'CSCI40 Section'
,
max_length
=
5
)
last_name
=
forms
.
CharField
(
label
=
'last_name'
,
max_length
=
50
)
age
=
forms
.
IntegerField
(
label
=
'Current Age'
)
age
=
forms
.
IntegerField
(
label
=
'age'
)
\ No newline at end of file
nationality
=
forms
.
CharField
(
label
=
'nationality'
,
max_length
=
50
)
bio
=
forms
.
TextField
(
label
=
'bio'
,
max_length
=
700
)
class
BookForm
(
forms
.
Form
):
title
=
forms
.
CharField
(
label
=
'title'
,
max_length
=
50
)
author
=
forms
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
publisher
=
forms
.
CharField
(
label
=
'publisher'
,
max_length
=
50
)
year_published
=
forms
.
IntegerField
(
label
=
'year_published'
,
max_length
=
50
)
ISBN
=
forms
.
CharField
(
label
=
'ISBN'
,
max_length
=
50
)
blurb
=
forms
.
CharField
(
label
=
'blurb'
,
max_length
=
50
)
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/add-book.html
View file @
e4cf8f0a
<form>
<form>
<label>
Full Name:
</label>
<label>
Title:
</label>
<input
id=
"name"
type=
"text"
name=
"section"
max
length=
"100"
required
/>
<input
id=
"title"
type=
"text"
name=
"title"
max
length=
"50"
required
/>
<label>
Full Name:
</label>
<label>
Author:
</label>
<input
id=
"section"
type=
"text"
name=
"section"
max
length=
"100"
required
/>
<input
id=
"author"
type=
"text"
name=
"author"
max
length=
"100"
required
/>
<label>
Full Name:
</label>
<label>
Publisher:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<label>
Year Published:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<label>
ISBN:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<label>
Blurb:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
</form>
</form>
\ No newline at end of file
janang_reading/bookshelf/views.py
View file @
e4cf8f0a
...
@@ -17,6 +17,15 @@ class AuthorView(ListView):
...
@@ -17,6 +17,15 @@ class AuthorView(ListView):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
author_data
=
Author
.
objects
.
all
()
.
values
()
author_data
=
Author
.
objects
.
all
()
.
values
()
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
'Jan'
,
'author_data'
:
author_data
})
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
'Jan'
,
'author_data'
:
author_data
})
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
first_name
=
request
.
POST
.
get
(
'first_name'
)
last_name
=
request
.
POST
.
get
(
'last_name'
)
age
=
request
.
POST
.
get
(
'age'
)
nationality
=
request
.
POST
.
get
(
'nationality'
)
bio
=
request
.
POST
.
get
(
'bio'
)
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
class
AuthorDetailView
(
DetailView
):
class
AuthorDetailView
(
DetailView
):
pk_url_kwarg
=
'id'
pk_url_kwarg
=
'id'
...
@@ -31,6 +40,15 @@ class BooksView(ListView):
...
@@ -31,6 +40,15 @@ class BooksView(ListView):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
book_data
=
Books
.
objects
.
all
()
.
values
()
book_data
=
Books
.
objects
.
all
()
.
values
()
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
'Jan'
,
'book_data'
:
book_data
})
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
'Jan'
,
'book_data'
:
book_data
})
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
title
=
request
.
POST
.
get
(
'title'
)
author
=
request
.
POST
.
get
(
'author'
)
publisher
=
request
.
POST
.
get
(
'apublisherge'
)
year_published
=
request
.
POST
.
get
(
'year_published'
)
ISBN
=
request
.
POST
.
get
(
'ISBN'
)
blurb
=
request
.
POST
.
get
(
'blurb'
)
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
class
BookDetailView
(
DetailView
):
class
BookDetailView
(
DetailView
):
pk_url_kwarg
=
'id'
pk_url_kwarg
=
'id'
...
...
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