Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rachpurisima_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
Rachel
rachpurisima_reading
Commits
7e8679f1
Commit
7e8679f1
authored
Apr 25, 2023
by
rachbit
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented user forms in add-book.html
parent
50c99387
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
12 deletions
+88
-12
forms.py
rachpurisima_reading/bookshelf/forms.py
+8
-0
add-book.html
...isima_reading/bookshelf/templates/bookshelf/add-book.html
+24
-0
edit-book.html
...sima_reading/bookshelf/templates/bookshelf/edit-book.html
+16
-0
home.html
rachpurisima_reading/bookshelf/templates/bookshelf/home.html
+2
-0
urls.py
rachpurisima_reading/bookshelf/urls.py
+10
-7
views.py
rachpurisima_reading/bookshelf/views.py
+19
-1
base.html
rachpurisima_reading/templates/base.html
+9
-4
No files found.
rachpurisima_reading/bookshelf/forms.py
0 → 100644
View file @
7e8679f1
from
django
import
forms
from
.models
import
Books
class
BookForm
(
forms
.
Form
):
class
Meta
:
model
=
Books
fields
=
'__all__'
rachpurisima_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
7e8679f1
{% extends 'base.html' %}
{% load static %}
{% block title %}Add a Book{% endblock %}
{% block header %}
<cite><h1
class=
"text-center"
>
Hindi pa ba ako sapat?
</h1></cite>
{% endblock %}
{% block subtitle %}
<p
class=
"text-center"
>
feel free to add more books to my collection.
<br>
-
</p>
{% endblock %}
<div
class=
"text-center"
>
</div>
{% block form %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
</div>
{% endblock %}
rachpurisima_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
7e8679f1
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<div
class=
"text-center"
>
<br>
<br>
<form
method=
"post"
>
{% csrf_token %}
{% for field in form %}
{{field.label}}:{{field}}
<br><br>
{% endfor %}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
</div>
{% endblock %}
rachpurisima_reading/bookshelf/templates/bookshelf/home.html
View file @
7e8679f1
...
@@ -21,4 +21,6 @@
...
@@ -21,4 +21,6 @@
<li><a
href=
"#"
>
Home
</a></li>
<li><a
href=
"#"
>
Home
</a></li>
<li><a
href=
"/bookshelf/books"
>
Books
</a></li>
<li><a
href=
"/bookshelf/books"
>
Books
</a></li>
<li><a
href=
"/bookshelf/authors"
>
Authors
</a></li>
<li><a
href=
"/bookshelf/authors"
>
Authors
</a></li>
<li><a
href=
"/bookshelf/books/add"
>
Add Book
</a></li>
<li><a
href=
"#"
>
Add Author
</a></li>
{% endblock %}
{% endblock %}
rachpurisima_reading/bookshelf/urls.py
View file @
7e8679f1
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
,
home
,
BooksView
,
AuthorsView
,
BookDetailView
,
AuthorDetailView
from
.views
import
index
,
home
,
BooksView
,
AuthorsView
,
BookDetailView
,
AuthorDetailView
,
BookCreateView
,
BookUpdateView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'authors'
),
path
(
'books/<int:pk>/details/'
,
BookDetailView
.
as_view
(),
name
=
'book_details'
),
path
(
'books/<int:pk>/details/'
,
BookDetailView
.
as_view
(),
name
=
'book_details'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author_details'
)
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author_details'
),
path
(
'books/add/'
,
BookCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit/'
,
BookUpdateView
.
as_view
(),
name
=
'edit-book'
),
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
rachpurisima_reading/bookshelf/views.py
View file @
7e8679f1
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.views.generic
import
ListView
,
DetailView
from
django.views.generic
import
ListView
,
DetailView
,
CreateView
,
UpdateView
from
.models
import
Author
,
Book
from
.models
import
Author
,
Book
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
'honk honk'
)
return
HttpResponse
(
'honk honk'
)
def
home
(
request
):
def
home
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'home'
})
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'home'
})
class
BooksView
(
ListView
):
class
BooksView
(
ListView
):
model
=
Book
model
=
Book
template_name
=
'bookshelf/books.html'
template_name
=
'bookshelf/books.html'
class
BookDetailView
(
DetailView
):
class
BookDetailView
(
DetailView
):
model
=
Book
model
=
Book
template_name
=
'bookshelf/book_details.html'
template_name
=
'bookshelf/book_details.html'
class
BookCreateView
(
CreateView
):
model
=
Book
fields
=
'__all__'
template_name
=
"bookshelf/add-book.html"
class
BookUpdateView
(
UpdateView
):
model
=
Book
fields
=
'__all__'
template_name
=
"bookshelf/edit-book.html"
class
AuthorsView
(
ListView
):
class
AuthorsView
(
ListView
):
model
=
Author
model
=
Author
template_name
=
'bookshelf/authors.html'
template_name
=
'bookshelf/authors.html'
class
AuthorDetailView
(
DetailView
):
class
AuthorDetailView
(
DetailView
):
model
=
Author
model
=
Author
template_name
=
'bookshelf/author_details.html'
template_name
=
'bookshelf/author_details.html'
rachpurisima_reading/templates/base.html
View file @
7e8679f1
...
@@ -10,6 +10,10 @@
...
@@ -10,6 +10,10 @@
color
:
white
;
color
:
white
;
text-decoration-style
:
solid
;
text-decoration-style
:
solid
;
}
}
form
{
margin
:
0
auto
;
width
:
300px
;
}
</style>
</style>
<title>
{% block title %}My amazing site{% endblock %}
</title>
<title>
{% block title %}My amazing site{% endblock %}
</title>
<nav
class=
"navbar navbar-custom"
>
<nav
class=
"navbar navbar-custom"
>
...
@@ -34,12 +38,13 @@
...
@@ -34,12 +38,13 @@
<div
class=
"text-left"
>
<div
class=
"text-left"
>
{% block content %}{% endblock %}
{% block content %}{% endblock %}
</div>
</div>
<div
class=
"text-right"
>
<figure
class=
"form form"
>
{% block form %}{% endblock %}
</figure>
</div>
</div>
</div>
</figure>
</figure>
</figure>
</figure>
</div>
<br><br><br>
{% block scripts %}{% endblock %}
</body>
</body>
</html>
</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