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
2a66faa4
Commit
2a66faa4
authored
Apr 25, 2023
by
Jan Ericsson Ong Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edited all 4 forms htmls
parent
dfc01886
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
131 additions
and
41 deletions
+131
-41
forms.cpython-310.pyc
janang_reading/bookshelf/__pycache__/forms.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
janang_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
janang_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
add-author.html
janang_reading/bookshelf/templates/bookshelf/add-author.html
+26
-12
add-book.html
janang_reading/bookshelf/templates/bookshelf/add-book.html
+28
-14
edit-author.html
...ng_reading/bookshelf/templates/bookshelf/edit-author.html
+26
-0
edit-book.html
janang_reading/bookshelf/templates/bookshelf/edit-book.html
+28
-0
urls.py
janang_reading/bookshelf/urls.py
+4
-0
views.py
janang_reading/bookshelf/views.py
+19
-15
No files found.
janang_reading/bookshelf/__pycache__/forms.cpython-310.pyc
0 → 100644
View file @
2a66faa4
File added
janang_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
2a66faa4
No preview for this file type
janang_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
2a66faa4
No preview for this file type
janang_reading/bookshelf/templates/bookshelf/add-author.html
View file @
2a66faa4
<form>
<label>
First Name:
</label>
<input
id=
"first_name"
type=
"text"
name=
"first_name"
max
length=
"50"
required
/>
<label>
Last Name:
</label>
<input
id=
"last_name"
type=
"text"
name=
"last_name"
max
length=
"100"
required
/>
<label>
Age:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<label>
Nationality:
</label>
<input
id=
"nationality"
type=
"text"
name=
"nationality"
required
/>
<label>
Bio:
</label>
<input
id=
"bio"
type=
"text"
name=
"bio"
required
/>
</form>
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form>
<label>
First Name:
</label>
<input
id=
"first_name"
type=
"text"
name=
"first_name"
max
length=
"50"
required
/>
<label>
Last Name:
</label>
<input
id=
"last_name"
type=
"text"
name=
"last_name"
max
length=
"100"
required
/>
<label>
Age:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<label>
Nationality:
</label>
<input
id=
"nationality"
type=
"text"
name=
"nationality"
required
/>
<label>
Bio:
</label>
<input
id=
"bio"
type=
"text"
name=
"bio"
required
/>
</form>
<button
type=
"button"
>
<a
href=
"/bookshelf/authors/{{ author.id }}/details/"
>
Add Author
</a>
</button><br>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/add-book.html
View file @
2a66faa4
<form>
<label>
Title:
</label>
<input
id=
"title"
type=
"text"
name=
"title"
max
length=
"50"
required
/>
<label>
Author:
</label>
<input
id=
"author"
type=
"text"
name=
"author"
max
length=
"100"
required
/>
<label>
Publisher:
</label>
<input
id=
"publisher"
type=
"text"
name=
"publisher"
required
/>
<label>
Year Published:
</label>
<input
id=
"year_published"
type=
"number"
name=
"year_published"
required
/>
<label>
ISBN:
</label>
<input
id=
"ISBN"
type=
"number"
name=
"ISBN"
required
/>
<label>
Blurb:
</label>
<input
id=
"blurb"
type=
"text"
name=
"blurb"
required
/>
</form>
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form>
<label>
Title:
</label>
<input
id=
"title"
type=
"text"
name=
"title"
max
length=
"50"
required
/>
<label>
Author:
</label>
<input
id=
"author"
type=
"text"
name=
"author"
max
length=
"100"
required
/>
<label>
Publisher:
</label>
<input
id=
"publisher"
type=
"text"
name=
"publisher"
required
/>
<label>
Year Published:
</label>
<input
id=
"year_published"
type=
"number"
name=
"year_published"
required
/>
<label>
ISBN:
</label>
<input
id=
"ISBN"
type=
"number"
name=
"ISBN"
required
/>
<label>
Blurb:
</label>
<input
id=
"blurb"
type=
"text"
name=
"blurb"
required
/>
</form>
<button
type=
"button"
>
<a
href=
"/bookshelf/books/{{ book.id }}/details/"
>
Add Book
</a>
</button><br>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/edit-author.html
View file @
2a66faa4
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Author{% endblock %}
{% block content %}
<form>
<label>
First Name:
</label>
<input
id=
"first_name"
type=
"text"
name=
"first_name"
max
length=
"50"
required
/>
<label>
Last Name:
</label>
<input
id=
"last_name"
type=
"text"
name=
"last_name"
max
length=
"100"
required
/>
<label>
Age:
</label>
<input
id=
"age"
type=
"number"
name=
"age"
required
/>
<label>
Nationality:
</label>
<input
id=
"nationality"
type=
"text"
name=
"nationality"
required
/>
<label>
Bio:
</label>
<input
id=
"bio"
type=
"text"
name=
"bio"
required
/>
</form>
<button
type=
"button"
>
<a
href=
"/bookshelf/authors/{{ author.id }}/details/"
>
Add Author
</a>
</button><br>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/edit-book.html
View file @
2a66faa4
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form>
<label>
Title:
</label>
<input
id=
"title"
type=
"text"
name=
"title"
max
length=
"50"
required
/>
<label>
Author:
</label>
<input
id=
"author"
type=
"text"
name=
"author"
max
length=
"100"
required
/>
<label>
Publisher:
</label>
<input
id=
"publisher"
type=
"text"
name=
"publisher"
required
/>
<label>
Year Published:
</label>
<input
id=
"year_published"
type=
"number"
name=
"year_published"
required
/>
<label>
ISBN:
</label>
<input
id=
"ISBN"
type=
"number"
name=
"ISBN"
required
/>
<label>
Blurb:
</label>
<input
id=
"blurb"
type=
"text"
name=
"blurb"
required
/>
</form>
<button
type=
"button"
>
<a
href=
"/bookshelf/books/{{ book.id }}/details/"
>
Add Book
</a>
</button><br>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/urls.py
View file @
2a66faa4
...
...
@@ -8,8 +8,12 @@ urlpatterns = [
path
(
''
,
views
.
HomeView
,
name
=
'home'
),
path
(
'authors/'
,
AuthorView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/<int:id>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'authors/<int:id>/add/'
,
AuthorDetailView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:id>/edit/'
,
AuthorDetailView
.
as_view
(),
name
=
'edit-author'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:id>/details/'
,
BookDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/<int:id>/add/'
,
BookDetailView
.
as_view
(),
name
=
'add-books'
),
path
(
'books/<int:id>/edit/'
,
BookDetailView
.
as_view
(),
name
=
'edit-books'
),
]
app_name
=
'bookshelf'
\ No newline at end of file
janang_reading/bookshelf/views.py
View file @
2a66faa4
...
...
@@ -3,6 +3,7 @@ from django.views import View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
.models
import
Author
,
Books
from
.
forms
import
AuthorForm
,
BookForm
# Create your views here.
...
...
@@ -17,14 +18,16 @@ class AuthorView(ListView):
def
get
(
self
,
request
):
author_data
=
Author
.
objects
.
all
()
.
values
()
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
'Jan'
,
'author_data'
:
author_data
})
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'form'
]
=
AuthorForm
()
return
context
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
)
form
=
AuthorForm
(
request
.
POST
)
if
form
.
is_valid
():
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
else
:
return
render
(
request
,
self
.
template_name
,
{
'form'
:
form
})
class
AuthorDetailView
(
DetailView
):
...
...
@@ -40,15 +43,16 @@ class BooksView(ListView):
def
get
(
self
,
request
):
book_data
=
Books
.
objects
.
all
()
.
values
()
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
'Jan'
,
'book_data'
:
book_data
})
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'form'
]
=
BookForm
()
return
context
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
)
form
=
BookForm
(
request
.
POST
)
if
form
.
is_valid
():
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
else
:
return
render
(
request
,
self
.
template_name
,
{
'form'
:
form
})
class
BookDetailView
(
DetailView
):
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