Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alliyah_marcelo_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
Alliyah Ericka Therese E. Marcelo
alliyah_marcelo_reading
Commits
1d05afbd
Commit
1d05afbd
authored
Apr 25, 2023
by
Alliyah Marcelo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented Add New Book and Add New Author pages.
parent
28bfb399
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
120 additions
and
4 deletions
+120
-4
urls.cpython-39.pyc
...g/alliyah_marcelo_reading/__pycache__/urls.cpython-39.pyc
+0
-0
forms.cpython-39.pyc
...arcelo_reading/bookshelf/__pycache__/forms.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
...marcelo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...arcelo_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
forms.py
alliyah_marcelo_reading/bookshelf/forms.py
+28
-0
add-author.html
...elo_reading/bookshelf/templates/bookshelf/add-author.html
+12
-0
add-book.html
...rcelo_reading/bookshelf/templates/bookshelf/add-book.html
+12
-0
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+4
-0
edit-author.html
...lo_reading/bookshelf/templates/bookshelf/edit-author.html
+12
-0
edit-book.html
...celo_reading/bookshelf/templates/bookshelf/edit-book.html
+12
-0
home.html
...h_marcelo_reading/bookshelf/templates/bookshelf/home.html
+3
-1
urls.py
alliyah_marcelo_reading/bookshelf/urls.py
+5
-1
views.py
alliyah_marcelo_reading/bookshelf/views.py
+32
-2
No files found.
alliyah_marcelo_reading/alliyah_marcelo_reading/__pycache__/urls.cpython-39.pyc
View file @
1d05afbd
No preview for this file type
alliyah_marcelo_reading/bookshelf/__pycache__/forms.cpython-39.pyc
0 → 100644
View file @
1d05afbd
File added
alliyah_marcelo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
1d05afbd
No preview for this file type
alliyah_marcelo_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
1d05afbd
No preview for this file type
alliyah_marcelo_reading/bookshelf/forms.py
0 → 100644
View file @
1d05afbd
from
django
import
forms
from
.models
import
Author
,
Books
class
BooksForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Books
fields
=
[
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
]
class
AuthorForm
(
forms
.
Form
):
class
Meta
:
model
=
Author
fields
=
[
'first_name'
,
'last_name'
,
'age'
,
'nationality'
,
'bio'
]
alliyah_marcelo_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
1d05afbd
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Author"
>
</form>
{% endblock %}
\ No newline at end of file
alliyah_marcelo_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
1d05afbd
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
\ No newline at end of file
alliyah_marcelo_reading/bookshelf/templates/bookshelf/author_details.html
View file @
1d05afbd
...
...
@@ -12,6 +12,10 @@
<br>
{{ object.bio }}
<br><br>
<a
href=
"{{ AuthorUpdateView.get_absolute_url }}"
>
<input
type=
"submit"
value=
"Edit Author"
>
</a>
<br><br>
Books by {{ object }} I love:
<br>
{% for book in books %}
...
...
alliyah_marcelo_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
1d05afbd
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Author{% endblock %}
{% block content %}
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
alliyah_marcelo_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
1d05afbd
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form
action=
"/"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
alliyah_marcelo_reading/bookshelf/templates/bookshelf/home.html
View file @
1d05afbd
...
...
@@ -10,5 +10,7 @@ Alliyah's preferred genre when reading books usually centers around dark themes-
Accordingly, some notable authors she likes are Fyodor Dostoevsky and F.H. Batacan.
<br>
<br>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
 
<a
href=
"/bookshelf/books/"
>
Books
</a>
   
<a
href=
"/bookshelf/authors/"
>
Authors
</a>
<br>
<a
href=
"/bookshelf/books/add/"
>
Add Book
</a>
 
<a
href=
"/bookshelf/authors/add/"
>
Add Author
</a>
{% endblock %}
\ No newline at end of file
alliyah_marcelo_reading/bookshelf/urls.py
View file @
1d05afbd
from
django.urls
import
path
from
.views
import
home_view
,
BooksListView
,
BooksDetailsView
,
AuthorListView
,
AuthorDetails
View
from
.views
import
home_view
,
BooksListView
,
BooksDetailsView
,
BooksCreateView
,
BooksUpdateView
,
AuthorListView
,
AuthorDetailsView
,
AuthorCreateView
,
AuthorUpdate
View
urlpatterns
=
[
...
...
@@ -9,6 +9,10 @@ urlpatterns = [
path
(
'books/<int:pk>/details/'
,
BooksDetailsView
.
as_view
(),
name
=
'book-detail'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors'
),
path
(
'author/<int:pk>/details/'
,
AuthorDetailsView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit'
,
BooksUpdateView
.
as_view
(),
name
=
'edit-book'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:pk>/edit'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
alliyah_marcelo_reading/bookshelf/views.py
View file @
1d05afbd
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
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
from
.forms
import
BooksForm
,
AuthorForm
def
home_view
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'name'
:
'Alliyah'
})
...
...
@@ -19,6 +21,18 @@ class BooksDetailsView(DetailView):
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/edit-book.html'
class
AuthorListView
(
ListView
):
model
=
Author
template_name
=
'bookshelf/authors.html'
...
...
@@ -31,4 +45,20 @@ class AuthorDetailsView(DetailView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'books'
]
=
Books
.
objects
.
all
()
return
context
\ No newline at end of file
return
context
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'
def
get_absolute_url
(
self
):
return
redirect
(
'bookshelf:edit-author'
,
kwargs
=
{
'pk'
:
self
.
pk
})
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