Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gab_salas_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
Jose Gabriel L. Salas
gab_salas_reading
Commits
824e5edd
Commit
824e5edd
authored
Apr 25, 2023
by
Jose Gabriel L. Salas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added books and authors add pages with submit option
parent
0d6e90be
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
88 additions
and
6 deletions
+88
-6
forms.cpython-310.pyc
...salas_reading/bookshelf/__pycache__/forms.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
gab_salas_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...salas_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
forms.py
gab_salas_reading/bookshelf/forms.py
+18
-0
add-author.html
...las_reading/bookshelf/templates/bookshelf/add-author.html
+11
-0
add-book.html
...salas_reading/bookshelf/templates/bookshelf/add-book.html
+11
-0
book_details.html
...s_reading/bookshelf/templates/bookshelf/book_details.html
+0
-0
edit-author.html
...as_reading/bookshelf/templates/bookshelf/edit-author.html
+11
-0
home.html
gab_salas_reading/bookshelf/templates/bookshelf/home.html
+5
-2
urls.py
gab_salas_reading/bookshelf/urls.py
+8
-3
views.py
gab_salas_reading/bookshelf/views.py
+24
-1
No files found.
gab_salas_reading/bookshelf/__pycache__/forms.cpython-310.pyc
0 → 100644
View file @
824e5edd
File added
gab_salas_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
824e5edd
No preview for this file type
gab_salas_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
824e5edd
No preview for this file type
gab_salas_reading/bookshelf/forms.py
0 → 100644
View file @
824e5edd
from
django
import
forms
from
.models
import
Books
,
Author
class
AddBookForm
(
forms
.
Form
):
title
=
forms
.
CharField
(
label
=
'title'
,
max_length
=
100
)
author
=
forms
.
CharField
(
label
=
'author'
,
max_length
=
100
)
publisher
=
forms
.
CharField
(
label
=
'publisher'
,
max_length
=
100
)
year_published
=
forms
.
IntegerField
(
label
=
'year_published'
)
ISBN
=
forms
.
IntegerField
(
label
=
'ISBN'
)
blurb
=
forms
.
CharField
(
label
=
'blurb'
,
max_length
=
500
)
class
BookForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Books
fields
=
[
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
]
\ No newline at end of file
gab_salas_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
824e5edd
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form
action =
""
"
method =
"post"
>
{% csrf_token %}
{{ form.as_p }}
<p><input
type=
"submit"
value =
"Add Author"
></p>
</form>
{% endblock %}
\ No newline at end of file
gab_salas_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
824e5edd
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<p><input
type=
"submit"
value=
"Add Book"
></p>
</form>
{% endblock %}
\ No newline at end of file
gab_salas_reading/bookshelf/templates/bookshelf/book
s_detail
.html
→
gab_salas_reading/bookshelf/templates/bookshelf/book
_details
.html
View file @
824e5edd
File moved
gab_salas_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
824e5edd
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Author{% endblock %}
{% block content %}
<form
action =
""
method =
"post"
>
{% csrf_token %}
{{ form.as_p }}
<p><input
type=
"submit"
value =
"Save Changes"
></p>
</form>
{% endblock %}
\ No newline at end of file
gab_salas_reading/bookshelf/templates/bookshelf/home.html
View file @
824e5edd
...
...
@@ -4,6 +4,9 @@
{% block content %}
<h1>
Welcome to Gab's Database of Favorite Books and Authors!
</h1>
<p>
I typically enjoy reading books with thought provoking topics, horrific themes, and myseterious plots. Authors that specializes in these appeal to me the most.
</p>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
<a
href=
"/bookshelf/books/"
><center>
Books
</a>
 
<a
href=
"/bookshelf/authors/"
>
Authors
</center></a><br>
<a
href=
"/bookshelf/books/add"
><center>
Add Book
</a>
 
<a
href=
"/bookshelf/authors/add"
>
Add Author
</center></a>
{% endblock %}
\ No newline at end of file
gab_salas_reading/bookshelf/urls.py
View file @
824e5edd
from
django.urls
import
path
from
.views
import
index
,
BooksListView
,
AuthorListView
,
BooksDetailView
,
AuthorDetailView
from
.views
import
index
,
BooksListView
,
AuthorListView
,
BooksDetailView
,
AuthorDetailView
,
AuthorCreateView
,
AuthorUpdateView
,
BookCreateView
,
BookUpdateView
urlpatterns
=
[
path
(
'home/'
,
index
,
name
=
'index'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'author-list'
),
path
(
'books/<int:pk>'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'authors/<int:pk>'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-detail'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-detail'
),
# path('books/add/', AddBookView.as_view(), name = 'add-book'),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:pk>/edit'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
),
path
(
'books/add/'
,
BookCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit'
,
BookUpdateView
.
as_view
(),
name
=
'edit-book'
),
]
...
...
gab_salas_reading/bookshelf/views.py
View file @
824e5edd
#from django.shortcuts import render
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.views
import
View
from
.models
import
Books
,
Author
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
.forms
import
AddBookForm
,
BookForm
from
django.views.generic.edit
import
CreateView
,
UpdateView
def
index
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'Gab'
})
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
class
AuthorUpdateView
(
UpdateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/edit-author.html'
class
BookCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
BookUpdateView
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/edit-book.html'
class
BooksListView
(
ListView
):
model
=
Books
template_name
=
"bookshelf/books.html"
class
BooksDetailView
(
DetailView
):
model
=
Books
template_name
=
"bookshelf/book_details.html"
...
...
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