Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
luigirodriguez_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
Neal Luigi D. Rodriguez
luigirodriguez_reading
Commits
fee1f85e
Commit
fee1f85e
authored
Apr 25, 2023
by
Neal Luigi D. Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add book has been created
parent
9067f927
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
50 additions
and
7 deletions
+50
-7
forms.cpython-39.pyc
...riguez_reading/bookshelf/__pycache__/forms.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
...driguez_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...riguez_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
forms.py
luigirodriguez_reading/bookshelf/forms.py
+10
-1
add-book.html
...iguez_reading/bookshelf/templates/bookshelf/add-book.html
+11
-0
home.html
...rodriguez_reading/bookshelf/templates/bookshelf/home.html
+1
-1
urls.py
luigirodriguez_reading/bookshelf/urls.py
+5
-2
views.py
luigirodriguez_reading/bookshelf/views.py
+23
-3
db.sqlite3
luigirodriguez_reading/db.sqlite3
+0
-0
No files found.
luigirodriguez_reading/bookshelf/__pycache__/forms.cpython-39.pyc
View file @
fee1f85e
No preview for this file type
luigirodriguez_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
fee1f85e
No preview for this file type
luigirodriguez_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
fee1f85e
No preview for this file type
luigirodriguez_reading/bookshelf/forms.py
View file @
fee1f85e
...
@@ -4,4 +4,13 @@ from .models import Author, Books
...
@@ -4,4 +4,13 @@ from .models import Author, Books
class
AuthorForm
(
forms
.
ModelForm
):
class
AuthorForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
model
=
Author
model
=
Author
fields
=
[
'first_name'
,
'last_name'
,
'age'
,
'nationality'
,
'bio'
]
fields
=
[
'first_name'
,
'last_name'
,
\ No newline at end of file
'age'
,
'nationality'
,
'bio'
]
class
BookForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Books
fields
=
[
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
]
\ No newline at end of file
luigirodriguez_reading/bookshelf/templates/bookshelf/add-book.html
View file @
fee1f85e
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Book {% endblock %}
{% block content %}
<h1>
Add New Book
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
\ No newline at end of file
luigirodriguez_reading/bookshelf/templates/bookshelf/home.html
View file @
fee1f85e
...
@@ -12,5 +12,5 @@
...
@@ -12,5 +12,5 @@
</p>
</p>
<br>
<br>
<p><a
href=
"http://127.0.0.1:8000/bookshelf/books"
>
Books
</a>
<a
href=
"http://127.0.0.1:8000/bookshelf/authors"
>
Authors
</a>
</p>
<p><a
href=
"http://127.0.0.1:8000/bookshelf/books"
>
Books
</a>
<a
href=
"http://127.0.0.1:8000/bookshelf/authors"
>
Authors
</a>
</p>
<p><a
href=
"http://127.0.0.1:8000/bookshelf/
authors/add/"
>
Add Author
</a>
</p>
<p><a
href=
"http://127.0.0.1:8000/bookshelf/
books/add/"
>
Add Book
</a>
<a
href=
"http://127.0.0.1:8000/bookshelf/authors/add/"
>
Add Author
</a>
</p>
{% endblock %}
{% endblock %}
\ No newline at end of file
luigirodriguez_reading/bookshelf/urls.py
View file @
fee1f85e
...
@@ -2,6 +2,7 @@ from django.urls import path
...
@@ -2,6 +2,7 @@ from django.urls import path
from
.views
import
(
home_view
,
from
.views
import
(
home_view
,
BooksListView
,
BooksDetailView
,
BooksListView
,
BooksDetailView
,
BooksCreateView
,
BooksUpdateView
,
AuthorsListView
,
AuthorsDetailView
,
AuthorsListView
,
AuthorsDetailView
,
AuthorsCreateView
,
AuthorsUpdateView
AuthorsCreateView
,
AuthorsUpdateView
)
)
...
@@ -9,11 +10,13 @@ from .views import (home_view,
...
@@ -9,11 +10,13 @@ from .views import (home_view,
urlpatterns
=
[
urlpatterns
=
[
path
(
'home'
,
home_view
,
name
=
'index'
),
path
(
'home'
,
home_view
,
name
=
'index'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/<pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'books-add'
),
path
(
'books/<pk>/edit/'
,
BooksUpdateView
.
as_view
(),
name
=
'books-edit'
),
path
(
'authors'
,
AuthorsListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors'
,
AuthorsListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<pk>/details/'
,
AuthorsDetailView
.
as_view
(),
name
=
'authors-detail'
),
path
(
'authors/<pk>/details/'
,
AuthorsDetailView
.
as_view
(),
name
=
'authors-detail'
),
path
(
'authors/add/'
,
AuthorsCreateView
.
as_view
(),
name
=
'authors-add'
),
path
(
'authors/add/'
,
AuthorsCreateView
.
as_view
(),
name
=
'authors-add'
),
path
(
'authors/<pk>/edit/'
,
AuthorsUpdateView
,
name
=
'authors-edit'
)
path
(
'authors/<pk>/edit/'
,
AuthorsUpdateView
.
as_view
()
,
name
=
'authors-edit'
)
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
\ No newline at end of file
luigirodriguez_reading/bookshelf/views.py
View file @
fee1f85e
...
@@ -7,7 +7,7 @@ from django.http import HttpResponse
...
@@ -7,7 +7,7 @@ from django.http import HttpResponse
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
from
.models
import
Author
,
Books
from
.models
import
Author
,
Books
from
.forms
import
AuthorForm
from
.forms
import
AuthorForm
,
BookForm
# Create your views here.
# Create your views here.
def
home_view
(
request
):
def
home_view
(
request
):
...
@@ -31,7 +31,7 @@ class AuthorsCreateView(CreateView):
...
@@ -31,7 +31,7 @@ class AuthorsCreateView(CreateView):
class
AuthorsUpdateView
(
UpdateView
):
class
AuthorsUpdateView
(
UpdateView
):
model
=
Author
model
=
Author
field
=
'__all__'
field
s
=
'__all__'
template_name
=
'bookshelf/authors_details.html'
template_name
=
'bookshelf/authors_details.html'
class
BooksListView
(
ListView
):
class
BooksListView
(
ListView
):
...
@@ -45,6 +45,16 @@ class BooksDetailView(DetailView):
...
@@ -45,6 +45,16 @@ class BooksDetailView(DetailView):
model
=
Books
model
=
Books
template_name
=
'bookshelf/book_details.html'
template_name
=
'bookshelf/book_details.html'
class
BooksCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
BooksUpdateView
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/book_details.html'
def
author_view
(
request
):
def
author_view
(
request
):
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
AuthorForm
(
request
.
POST
)
form
=
AuthorForm
(
request
.
POST
)
...
@@ -54,3 +64,13 @@ def author_view(request):
...
@@ -54,3 +64,13 @@ def author_view(request):
else
:
else
:
form
=
AuthorForm
()
form
=
AuthorForm
()
return
render
(
request
,
'add-author.html'
,
{
'form'
:
form
})
return
render
(
request
,
'add-author.html'
,
{
'form'
:
form
})
def
book_view
(
request
):
if
request
.
method
==
'POST'
:
form
=
BookForm
(
request
.
POST
)
if
form
.
is_valid
():
new_author
=
form
.
save
()
return
redirect
(
AuthorsDetailView
,
pk
=
new_author
.
pk
)
else
:
form
=
AuthorForm
()
return
render
(
request
,
'add-book.html'
,
{
'form'
:
form
})
\ No newline at end of file
luigirodriguez_reading/db.sqlite3
View file @
fee1f85e
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