Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
andrada_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
Alvin Joshua Andrada
andrada_reading
Commits
95bf4d51
Commit
95bf4d51
authored
Apr 25, 2023
by
Alvin Joshua Andrada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented forms
parent
24cabb8d
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
134 additions
and
3 deletions
+134
-3
urls.cpython-39.pyc
andrada_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
andrada_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
forms.py
andrada_reading/bookshelf/forms.py
+9
-0
add-author.html
...ada_reading/bookshelf/templates/bookshelf/add-author.html
+23
-0
add-book.html
andrada_reading/bookshelf/templates/bookshelf/add-book.html
+23
-0
edit-author.html
...da_reading/bookshelf/templates/bookshelf/edit-author.html
+23
-0
edit-book.html
andrada_reading/bookshelf/templates/bookshelf/edit-book.html
+23
-0
home.html
andrada_reading/bookshelf/templates/bookshelf/home.html
+3
-1
urls.py
andrada_reading/bookshelf/urls.py
+7
-1
views.py
andrada_reading/bookshelf/views.py
+23
-1
No files found.
andrada_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
95bf4d51
No preview for this file type
andrada_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
95bf4d51
No preview for this file type
andrada_reading/bookshelf/forms.py
0 → 100644
View file @
95bf4d51
# forms bookshelf
from
django
import
forms
from
.models
import
Author
,
Books
class
BookForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Book
fields
=
[
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
]
andrada_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
95bf4d51
<!-- add-author html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
action=
"/authors"
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Add Author"
>
</form>
{% endblock %}
\ No newline at end of file
andrada_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
95bf4d51
<!-- add-book html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
action=
"/books"
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
\ No newline at end of file
andrada_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
95bf4d51
<!-- edit-author html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
action=
"home/authors"
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
andrada_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
95bf4d51
<!-- edit-book html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Book{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
action=
"home/books"
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
andrada_reading/bookshelf/templates/bookshelf/home.html
View file @
95bf4d51
...
...
@@ -9,5 +9,7 @@ in animes. I mostly read LitRPGs and Chinese genres. I often read in a
particular website wherein amateur writers upload this kind of work. Many
of them are actually good.
</p>
<a
href=
"authors/"
>
Authors
</a>
<a
href=
"books/"
>
Books
</a>
<a
href=
"books/"
>
Books
</a>
<br>
<a
href=
"books/add/"
>
Add Book
</a>
<a
href=
"authors/add/"
>
Add Author
</a>
{% endblock %}
\ No newline at end of file
andrada_reading/bookshelf/urls.py
View file @
95bf4d51
from
django.urls
import
path
from
.
import
views
from
.views
import
BooksView
,
AuthorsView
,
BookDetailView
,
AuthorDetailView
from
.views
import
(
BooksView
,
AuthorsView
,
BookDetailView
,
AuthorDetailView
,
BookCreateView
,
AuthorCreateView
,
BookUpdateView
,
AuthorUpdateView
)
urlpatterns
=
[
path
(
''
,
views
.
home_view
,
name
=
'home'
),
...
...
@@ -8,6 +10,10 @@ urlpatterns = [
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'author-list'
),
path
(
'books/<int:pk>/details'
,
BookDetailView
.
as_view
(),
name
=
'book-detail'
),
path
(
'authors/<int:author_id>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books/add/'
,
BookCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'books/<int:pk>/edit'
,
BookUpdateView
.
as_view
(),
name
=
'edit-book'
),
path
(
'authors/<int:pk>/edit'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
),
]
app_name
=
"bookshelf"
andrada_reading/bookshelf/views.py
View file @
95bf4d51
...
...
@@ -5,6 +5,8 @@ from django.views import View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Author
,
Books
def
home_view
(
request
):
...
...
@@ -27,3 +29,23 @@ class AuthorDetailView(View):
author
=
Author
.
objects
.
get
(
pk
=
author_id
)
books_list
=
Books
.
objects
.
all
()
.
filter
(
author
=
author
)
return
render
(
request
,
"bookshelf/author_details.html"
,
{
"author"
:
author
,
"books_list"
:
books_list
})
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
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
class
AuthorUpdateView
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/edit-author.html'
\ No newline at end of file
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