Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvaalvarez_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
Angelo Alvarez
alvaalvarez_reading
Commits
9287decf
Commit
9287decf
authored
Apr 25, 2023
by
Angelo Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Feature: Add Books and Add Authors
parent
75c51014
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
65 additions
and
2 deletions
+65
-2
urls.cpython-310.pyc
...lvarez_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...varez_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
add_author.html
...rez_reading/bookshelf/templates/bookshelf/add_author.html
+16
-0
add_book.html
...varez_reading/bookshelf/templates/bookshelf/add_book.html
+16
-0
home.html
alvaalvarez_reading/bookshelf/templates/bookshelf/home.html
+5
-0
urls.py
alvaalvarez_reading/bookshelf/urls.py
+8
-2
views.py
alvaalvarez_reading/bookshelf/views.py
+15
-0
style.css
alvaalvarez_reading/static/style.css
+5
-0
No files found.
alvaalvarez_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
9287decf
No preview for this file type
alvaalvarez_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
9287decf
No preview for this file type
alvaalvarez_reading/bookshelf/templates/bookshelf/add_author.html
0 → 100644
View file @
9287decf
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Author {% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{% for field in form %}
{{field.label}}: {{ field }}
<span
class=
"spacer"
></span>
{% endfor %}
<button
type=
"Submit"
>
Add Author
</button>
</form>
{% endblock %}
\ No newline at end of file
alvaalvarez_reading/bookshelf/templates/bookshelf/add_book.html
0 → 100644
View file @
9287decf
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Book {% endblock %}
{% block content %}
<form
method=
"POST"
>
{% csrf_token %}
{% for field in form %}
{{field.label}}: {{ field }}
<span
class=
"spacer"
></span>
{% endfor %}
<button
type=
"Submit"
>
Add Book
</button>
</form>
{% endblock %}
\ No newline at end of file
alvaalvarez_reading/bookshelf/templates/bookshelf/home.html
View file @
9287decf
...
@@ -31,6 +31,11 @@ works of classic literature as I progress through my college career.
...
@@ -31,6 +31,11 @@ works of classic literature as I progress through my college career.
<a
href=
"../authors/"
>
Authors
</a>
<a
href=
"../authors/"
>
Authors
</a>
</div>
</div>
<div
id=
"links"
style=
"margin: auto; text-align: center; width: 100%"
>
<a
href=
"../books/add"
>
Add Book
</a>
<a
href=
"../authors/add"
>
Add Author
</a>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
alvaalvarez_reading/bookshelf/urls.py
View file @
9287decf
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
home
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
from
.views
import
home
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
,
BooksCreateView
,
AuthorCreateView
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
#Books
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-details'
),
path
(
'books/<int:pk>/details/'
,
BooksDetailView
.
as_view
(),
name
=
'books-details'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
#Authors
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-details'
)
path
(
'authors/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'authors-details'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
]
]
# This might be needed, depending on your Django version
# This might be needed, depending on your Django version
...
...
alvaalvarez_reading/bookshelf/views.py
View file @
9287decf
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
from
django.views
import
View
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
from
.models
import
Books
,
Author
from
.models
import
Books
,
Author
# Create your views here.
# Create your views here.
...
@@ -9,6 +10,8 @@ from .models import Books, Author
...
@@ -9,6 +10,8 @@ from .models import Books, Author
def
home
(
request
):
def
home
(
request
):
return
render
(
request
,
'bookshelf/home.html'
)
return
render
(
request
,
'bookshelf/home.html'
)
##BOOKS
class
BooksListView
(
ListView
):
class
BooksListView
(
ListView
):
template_name
=
'bookshelf/books_list.html'
template_name
=
'bookshelf/books_list.html'
model
=
Books
model
=
Books
...
@@ -17,6 +20,13 @@ class BooksDetailView(DetailView):
...
@@ -17,6 +20,13 @@ class BooksDetailView(DetailView):
template_name
=
'bookshelf/books_detail.html'
template_name
=
'bookshelf/books_detail.html'
model
=
Books
model
=
Books
class
BooksCreateView
(
CreateView
):
template_name
=
'bookshelf/add_book.html'
model
=
Books
fields
=
'__all__'
##AUTHORS
class
AuthorListView
(
ListView
):
class
AuthorListView
(
ListView
):
template_name
=
'bookshelf/author_list.html'
template_name
=
'bookshelf/author_list.html'
model
=
Author
model
=
Author
...
@@ -26,3 +36,8 @@ class AuthorDetailView(DetailView):
...
@@ -26,3 +36,8 @@ class AuthorDetailView(DetailView):
model
=
Author
model
=
Author
booklist
=
Books
.
objects
.
all
()
booklist
=
Books
.
objects
.
all
()
extra_context
=
{
'books'
:
booklist
}
extra_context
=
{
'books'
:
booklist
}
class
AuthorCreateView
(
CreateView
):
template_name
=
'bookshelf/add_author.html'
model
=
Author
fields
=
'__all__'
\ No newline at end of file
alvaalvarez_reading/static/style.css
View file @
9287decf
...
@@ -36,4 +36,9 @@ h1 {
...
@@ -36,4 +36,9 @@ h1 {
ul
li
{
ul
li
{
background
:
#ddecfc
;
background
:
#ddecfc
;
margin
:
10px
;
margin
:
10px
;
}
.spacer
{
display
:
block
;
margin-bottom
:
0.5em
;
}
}
\ 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