Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
diannedelpilar_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
Fritzie Dianne Del Pilar
diannedelpilar_reading
Commits
8cbbe2ce
Commit
8cbbe2ce
authored
Apr 26, 2023
by
Fritzie Dianne Del Pilar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'lab04'
parents
d61be466
e863fc92
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
156 additions
and
19 deletions
+156
-19
README.txt
README.txt
+3
-3
forms.cpython-39.pyc
...lpilar_reading/bookshelf/__pycache__/forms.cpython-39.pyc
+0
-0
forms.py
diannedelpilar_reading/bookshelf/forms.py
+12
-0
books.jpg
diannedelpilar_reading/bookshelf/static/bookshelf/books.jpg
+0
-0
style.css
diannedelpilar_reading/bookshelf/static/bookshelf/style.css
+8
-1
add-author.html
...lar_reading/bookshelf/templates/bookshelf/add-author.html
+12
-0
add-book.html
...pilar_reading/bookshelf/templates/bookshelf/add-book.html
+12
-0
author_detail.html
..._reading/bookshelf/templates/bookshelf/author_detail.html
+8
-5
book_detail.html
...ar_reading/bookshelf/templates/bookshelf/book_detail.html
+6
-3
edit-author.html
...ar_reading/bookshelf/templates/bookshelf/edit-author.html
+11
-0
edit-book.html
...ilar_reading/bookshelf/templates/bookshelf/edit-book.html
+11
-0
home.html
...edelpilar_reading/bookshelf/templates/bookshelf/home.html
+14
-2
urls.py
diannedelpilar_reading/bookshelf/urls.py
+6
-2
views.py
diannedelpilar_reading/bookshelf/views.py
+53
-3
db.sqlite3
diannedelpilar_reading/db.sqlite3
+0
-0
No files found.
README.txt
View file @
8cbbe2ce
Fritzie Dianne Del Pilar, 211983, CSCI40-F
Fritzie Dianne Del Pilar, 211983, CSCI40-F
Lab 0
3: My Favorite Books and Authors
Lab 0
4: My Favorite Books and Authors v2
March 28
, 2023
April 25
, 2023
I, Fritzie Dianne Del Pilar, truthfully completed this lab work with the best of my ability and knowledge.
I, Fritzie Dianne Del Pilar, truthfully completed this lab work with the best of my ability and knowledge.
<sgd> Fritzie Dianne Del Pilar, March 27, 2023
<sgd> Fritzie Dianne Del Pilar, April 25, 2023
\ No newline at end of file
\ No newline at end of file
diannedelpilar_reading/bookshelf/__pycache__/forms.cpython-39.pyc
0 → 100644
View file @
8cbbe2ce
File added
diannedelpilar_reading/bookshelf/forms.py
0 → 100644
View file @
8cbbe2ce
from
django.forms
import
ModelForm
from
.models
import
Author
,
Book
class
BookForm
(
ModelForm
):
class
Meta
:
model
=
Book
fields
=
[
"title"
,
"author"
,
"publisher"
,
"year_published"
,
"ISBN"
,
"blurb"
,
]
class
AuthorForm
(
ModelForm
):
class
Meta
:
model
=
Author
fields
=
[
"first_name"
,
"last_name"
,
"age"
,
"nationality"
,
"bio"
,
]
diannedelpilar_reading/bookshelf/static/bookshelf/b
g
.jpg
→
diannedelpilar_reading/bookshelf/static/bookshelf/b
ooks
.jpg
View file @
8cbbe2ce
File moved
diannedelpilar_reading/bookshelf/static/bookshelf/style.css
View file @
8cbbe2ce
...
@@ -22,7 +22,7 @@ h2 {
...
@@ -22,7 +22,7 @@ h2 {
}
}
body
{
body
{
background-image
:
url("/static/bookshelf/b
g
.jpg")
;
background-image
:
url("/static/bookshelf/b
ooks
.jpg")
;
background-repeat
:
no-repeat
;
background-repeat
:
no-repeat
;
background-size
:
cover
;
background-size
:
cover
;
background-position
:
center
;
background-position
:
center
;
...
@@ -36,6 +36,13 @@ a{
...
@@ -36,6 +36,13 @@ a{
font-size
:
25px
;
font-size
:
25px
;
}
}
a
:hover
{
color
:
red
;
font-family
:
monaco
;
font-weight
:
bold
;
font-size
:
25px
;
}
ol
{
ol
{
font-size
:
40px
;
font-size
:
40px
;
font-family
:
monaco
;
font-family
:
monaco
;
...
...
diannedelpilar_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
8cbbe2ce
{% extends "base.html" %}
{% block page-title %}Add New Author{% endblock %}
{% block content %}
<form
method=
"POST"
action=
"{% url 'bookshelf:add_author' %}"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{ form.as_p }}
<button
class=
"button"
type=
"Add Author"
>
Add Author
</button>
</form>
{% endblock %}
\ No newline at end of file
diannedelpilar_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
8cbbe2ce
{% extends "base.html" %}
{% block page-title %}Add New Book{% endblock %}
{% block content %}
<form
method=
"POST"
action=
"{% url 'bookshelf:add_book' %}"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{ form.as_p }}
<button
class=
"button"
type=
"Add Book"
>
Add Book
</button>
</form>
{% endblock %}
\ No newline at end of file
diannedelpilar_reading/bookshelf/templates/bookshelf/author_detail.html
View file @
8cbbe2ce
...
@@ -7,10 +7,14 @@
...
@@ -7,10 +7,14 @@
<head>
<head>
<h1><u>
{{author.first_name}} {{author.last_name}}
</u></h1>
<h1><u>
{{author.first_name}} {{author.last_name}}
</u></h1>
<h2
>
{{ author.age }} years old
</h2>
<h2
>
{{ author.age }} years old
</h2>
<h2>
Nationality:
{{ author.nationality }}
</h2>
<h2>
{{ author.nationality }}
</h2>
<h2>
Bio:
<br>
{{ author.bio }}
</h2>
<h2>
Bio:
<br>
{{ author.bio }}
</h2>
</head>
</head>
<div
class=
"flex-parent jc-center"
>
<a
href=
"{% url 'bookshelf:edit_author' author.id %}"
type=
"button"
class=
"btn btn-outline-secondary"
>
Edit Author
</a>
</div>
<body>
<body>
<p>
Books by {{author.first_name}} {{author.last_name}} I love:
<p>
Books by {{author.first_name}} {{author.last_name}} I love:
<ul>
<ul>
...
@@ -24,10 +28,9 @@
...
@@ -24,10 +28,9 @@
</ul>
</ul>
</p>
</p>
<div
class=
"flex-parent jc-center"
>
<div
class =
"flex-parent jc-center"
>
<button
onclick=
"location.href = '/bookshelf/home'"
class=
"green margin-left"
>
Home
</button>
<a
href=
"{% url 'bookshelf:home' %}"
type=
"button"
class=
"margin-left"
>
Home
</a>
<button
onclick=
"location.href = '/bookshelf/home/books'"
class=
"blue"
>
Books
</button>
<a
href=
"{% url 'bookshelf:books' %}"
type=
"button"
class=
"jc-center"
>
Books
</a>
<button
onclick=
"location.href = '/bookshelf/home/authors'"
class=
"pink margin-right"
>
Authors
</button>
</div>
</div>
</body>
</body>
...
...
diannedelpilar_reading/bookshelf/templates/bookshelf/book_detail.html
View file @
8cbbe2ce
...
@@ -13,11 +13,14 @@
...
@@ -13,11 +13,14 @@
<h2>
"{{ book.blurb }}"
</h2>
<h2>
"{{ book.blurb }}"
</h2>
</head>
</head>
<div
class=
"flex-parent jc-center"
>
<a
href=
"{% url 'bookshelf:edit_book' book.id %}"
type=
"button"
class=
"btn btn-outline-secondary"
>
Edit Book
</a>
</div>
<body>
<body>
<div
class=
"flex-parent jc-center"
>
<div
class=
"flex-parent jc-center"
>
<button
onclick=
"location.href = '/bookshelf/home'"
class=
"green margin-left"
>
Home
</button>
<a
href=
"{% url 'bookshelf:home' %}"
type=
"button"
class=
"btn btn-outline-secondary"
>
Home
</a>
<button
onclick=
"location.href = '/bookshelf/home/books'"
class=
"blue"
>
Books
</button>
<a
href=
"{% url 'bookshelf:authors' %}"
type=
"button"
class=
"btn btn-outline-secondary"
>
Authors
</a>
<button
onclick=
"location.href = '/bookshelf/home/authors'"
class=
"pink margin-right"
>
Authors
</button>
</div>
</div>
</body>
</body>
...
...
diannedelpilar_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
8cbbe2ce
{% extends "base.html" %}
{% block page-title %}Edit Author{% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{form.as_p}}
<button
class=
"button"
type=
"submit"
>
Save Changes
</button>
</form>
{% endblock %}
diannedelpilar_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
8cbbe2ce
{% extends "base.html" %}
{% block page-title %}Edit Book{% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{{form.as_p}}
<button
class=
"button"
type=
"submit"
>
Save Changes
</button>
</form>
{% endblock %}
diannedelpilar_reading/bookshelf/templates/bookshelf/home.html
View file @
8cbbe2ce
...
@@ -18,8 +18,20 @@
...
@@ -18,8 +18,20 @@
</p>
</p>
<div
class=
"flex-parent jc-center"
>
<div
class=
"flex-parent jc-center"
>
<button
onclick=
"location.href = 'books/'"
class=
"blue margin-right"
>
Books
</button>
<a
href=
"{% url 'bookshelf:books' %}"
type=
"button"
class=
"jc-center"
>
Books
</a>
<button
onclick=
"location.href = 'authors/'"
class=
"pink"
>
Authors
</button>
<a
href=
"{% url 'bookshelf:authors' %}"
type=
"button"
class=
"margin-right"
>
Authors
</a>
</div>
<div
class=
"flex-parent jc-center"
>
<form
method=
"post"
action=
"books/add"
>
{% csrf_token %}
<button
type=
"submit"
>
Add Book
</button>
</form>
<form
method=
"post"
action=
"authors/add"
>
{% csrf_token %}
<button
type=
"submit"
>
Add Author
</button>
</form>
</div>
</div>
</body>
</body>
...
...
diannedelpilar_reading/bookshelf/urls.py
View file @
8cbbe2ce
...
@@ -4,10 +4,14 @@ from .views import home
...
@@ -4,10 +4,14 @@ from .views import home
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/books/'
,
views
.
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'home/books/'
,
views
.
BooksView
.
as_view
(),
name
=
"books"
),
path
(
'home/authors/'
,
views
.
AuthorsView
.
as_view
(),
name
=
'authors'
),
path
(
'home/authors/'
,
views
.
AuthorsView
.
as_view
(),
name
=
"authors"
),
path
(
'<int:book_id>/book_details'
,
views
.
BooksDetailView
.
as_view
(),
name
=
"book_detail"
),
path
(
'<int:book_id>/book_details'
,
views
.
BooksDetailView
.
as_view
(),
name
=
"book_detail"
),
path
(
'<int:author_id>/author_details'
,
views
.
AuthorsDetailView
.
as_view
(),
name
=
"author_detail"
),
path
(
'<int:author_id>/author_details'
,
views
.
AuthorsDetailView
.
as_view
(),
name
=
"author_detail"
),
path
(
'home/books/add'
,
views
.
AddBookView
.
as_view
(),
name
=
"add_book"
),
path
(
'home/authors/add'
,
views
.
AddAuthorView
.
as_view
(),
name
=
"add_author"
),
path
(
'books/<int:pk>/edit/'
,
views
.
BookEditView
.
as_view
(),
name
=
"edit_book"
),
path
(
'authors/<int:pk>/edit/'
,
views
.
AuthorEditView
.
as_view
(),
name
=
"edit_author"
),
]
]
app_name
=
'bookshelf'
app_name
=
'bookshelf'
\ No newline at end of file
diannedelpilar_reading/bookshelf/views.py
View file @
8cbbe2ce
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
reverse
from
django.http
import
Http
Response
,
Http
404
from
django.http
import
Http404
from
.models
import
Author
,
Book
from
.models
import
Author
,
Book
from
django.views
import
View
from
django.views
import
View
from
.forms
import
BookForm
,
AuthorForm
from
django.shortcuts
import
get_object_or_404
from
django.views.generic.edit
import
UpdateView
def
home
(
request
):
def
home
(
request
):
return
render
(
request
,
"bookshelf/home.html"
)
return
render
(
request
,
"bookshelf/home.html"
)
...
@@ -35,4 +39,50 @@ class AuthorsDetailView(View):
...
@@ -35,4 +39,50 @@ class AuthorsDetailView(View):
except
Author
.
DoesNotExist
:
except
Author
.
DoesNotExist
:
raise
Http404
(
"Author does not exist!"
)
raise
Http404
(
"Author does not exist!"
)
books_list
=
Book
.
objects
.
all
()
.
filter
(
author
=
author
)
books_list
=
Book
.
objects
.
all
()
.
filter
(
author
=
author
)
return
render
(
request
,
"bookshelf/author_detail.html"
,
{
"author"
:
author
,
"books_list"
:
books_list
})
return
render
(
request
,
"bookshelf/author_detail.html"
,
{
"author"
:
author
,
"books_list"
:
books_list
})
\ No newline at end of file
class
AddBookView
(
View
):
model
=
Book
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'form'
]
=
BookForm
()
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
BookForm
(
request
.
POST
)
if
form
.
is_valid
():
new_book
=
form
.
save
()
return
render
(
request
,
"bookshelf/book_detail.html"
,
{
'book'
:
new_book
})
else
:
return
render
(
request
,
"bookshelf/add-book.html"
,
{
'form'
:
form
})
class
AddAuthorView
(
View
):
model
=
Author
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'form'
]
=
AuthorForm
()
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
AuthorForm
(
request
.
POST
)
if
form
.
is_valid
():
new_author
=
form
.
save
()
return
render
(
request
,
"bookshelf/author_detail.html"
,
{
'author'
:
new_author
})
else
:
return
render
(
request
,
"bookshelf/add-author.html"
,
{
'form'
:
form
})
class
BookEditView
(
UpdateView
):
model
=
Book
fields
=
'__all__'
template_name
=
'bookshelf/edit-book.html'
def
get_success_url
(
self
):
return
reverse
(
'bookshelf:book_detail'
,
kwargs
=
{
'book_id'
:
self
.
object
.
pk
})
class
AuthorEditView
(
UpdateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/edit-author.html'
def
get_success_url
(
self
):
return
reverse
(
'bookshelf:author_detail'
,
kwargs
=
{
'author_id'
:
self
.
object
.
pk
})
\ No newline at end of file
diannedelpilar_reading/db.sqlite3
View file @
8cbbe2ce
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