Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
ronrodillas_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
Ron Rodillas
ronrodillas_reading
Commits
02fc622f
Commit
02fc622f
authored
May 01, 2023
by
Ron Rodillas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created the book and author edit detail pages
parent
fb4b63f6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
63 additions
and
3 deletions
+63
-3
models.cpython-39.pyc
...illas_reading/bookshelf/__pycache__/models.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
...odillas_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...dillas_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
models.py
ronrodillas_reading/bookshelf/models.py
+7
-1
author_detail.html
..._reading/bookshelf/templates/bookshelf/author_detail.html
+3
-1
books_detail.html
...s_reading/bookshelf/templates/bookshelf/books_detail.html
+2
-0
edit-author.html
...as_reading/bookshelf/templates/bookshelf/edit-author.html
+19
-0
edit-book.html
...llas_reading/bookshelf/templates/bookshelf/edit-book.html
+19
-0
urls.py
ronrodillas_reading/bookshelf/urls.py
+2
-0
views.py
ronrodillas_reading/bookshelf/views.py
+11
-1
No files found.
ronrodillas_reading/bookshelf/__pycache__/models.cpython-39.pyc
View file @
02fc622f
No preview for this file type
ronrodillas_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
02fc622f
No preview for this file type
ronrodillas_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
02fc622f
No preview for this file type
ronrodillas_reading/bookshelf/models.py
View file @
02fc622f
...
...
@@ -18,6 +18,9 @@ class Author(models.Model):
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:AuthorDetailView'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_update_url
(
self
):
return
reverse
(
'bookshelf:AuthorUpdateView'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
...
...
@@ -33,4 +36,7 @@ class Books(models.Model):
return
self
.
__str__
()
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:BookDetailView'
,
kwargs
=
{
'pk'
:
self
.
pk
})
\ No newline at end of file
return
reverse
(
'bookshelf:BookDetailView'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_update_url
(
self
):
return
reverse
(
'bookshelf:BookUpdateView'
,
kwargs
=
{
'pk'
:
self
.
pk
})
\ No newline at end of file
ronrodillas_reading/bookshelf/templates/bookshelf/author_detail.html
View file @
02fc622f
...
...
@@ -20,7 +20,9 @@ p1 {
{{object.age}}
<br>
{{object.nationality}}
<br>
</p1>
{{object.bio}}
<br>
{{object.bio}}
<br><br>
<a
href=
"{{object.get_update_url}}"
><button>
Edit Author
</button></a><br>
<br><br>
<h2>
Books by {{object.get_name}} I love:
</h2>
<p2></p2>
<div>
...
...
ronrodillas_reading/bookshelf/templates/bookshelf/books_detail.html
View file @
02fc622f
...
...
@@ -26,6 +26,8 @@ p1 {
<br>
<div>
<a
href=
"{{object.get_update_url}}"
><button>
Edit Book
</button></a><br>
<br><br>
<a
href=
"{% url 'bookshelf:home' %}"
>
Home
</a>
<a
href=
"{% url 'bookshelf:BooksView' %}"
>
Books
</a>
...
...
ronrodillas_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
02fc622f
{% extends 'base.html' %}
{% load static %}
{% block title %}
Add New Book
{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form
method=
"POST"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
ronrodillas_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
02fc622f
{% extends 'base.html' %}
{% load static %}
{% block title %}
Add New Book
{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<form
method=
"POST"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
ronrodillas_reading/bookshelf/urls.py
View file @
02fc622f
...
...
@@ -9,6 +9,8 @@ urlpatterns = [
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'AuthorDetailView'
),
path
(
'books/add'
,
BooksCreateView
.
as_view
(),
name
=
'AddBook'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'AddAuthor'
),
path
(
'books/<int:pk>/edit'
,
BookUpdateView
.
as_view
(),
name
=
'BookUpdateView'
),
path
(
'authors/<int:pk>/edit'
,
AuthorUpdateView
.
as_view
(),
name
=
'AuthorUpdateView'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
ronrodillas_reading/bookshelf/views.py
View file @
02fc622f
...
...
@@ -33,4 +33,14 @@ class BooksCreateView(CreateView):
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
\ No newline at end of file
template_name
=
'bookshelf/add-author.html'
class
BookUpdateView
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/edit-book.html'
class
AuthorUpdateView
(
UpdateView
):
model
=
Author
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