Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
luigirodriguez_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
Neal Luigi D. Rodriguez
luigirodriguez_reading
Commits
f434234e
Commit
f434234e
authored
Apr 26, 2023
by
Neal Luigi D. Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edit Book and Edit Author has been implemented
parent
fee1f85e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
5 deletions
+39
-5
models.cpython-39.pyc
...iguez_reading/bookshelf/__pycache__/models.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
...driguez_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...riguez_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
models.py
luigirodriguez_reading/bookshelf/models.py
+3
-0
edit-author.html
...ez_reading/bookshelf/templates/bookshelf/edit-author.html
+11
-0
edit-book.html
...guez_reading/bookshelf/templates/bookshelf/edit-book.html
+11
-0
views.py
luigirodriguez_reading/bookshelf/views.py
+14
-5
db.sqlite3
luigirodriguez_reading/db.sqlite3
+0
-0
No files found.
luigirodriguez_reading/bookshelf/__pycache__/models.cpython-39.pyc
View file @
f434234e
No preview for this file type
luigirodriguez_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
f434234e
No preview for this file type
luigirodriguez_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
f434234e
No preview for this file type
luigirodriguez_reading/bookshelf/models.py
View file @
f434234e
...
@@ -14,6 +14,9 @@ class Author(models.Model):
...
@@ -14,6 +14,9 @@ class Author(models.Model):
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:authors-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
return
reverse
(
'bookshelf:authors-detail'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_edit_url
(
self
):
return
reverse
(
'bookshelf:authors-edit'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Books
(
models
.
Model
):
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
1000
)
title
=
models
.
CharField
(
max_length
=
1000
)
...
...
luigirodriguez_reading/bookshelf/templates/bookshelf/edit-author.html
0 → 100644
View file @
f434234e
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Author {% endblock %}
{% block content %}
<h1>
Edit Author
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
luigirodriguez_reading/bookshelf/templates/bookshelf/edit-book.html
0 → 100644
View file @
f434234e
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Book {% endblock %}
{% block content %}
<h1>
Edit Book
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Save Changes"
>
</form>
{% endblock %}
\ No newline at end of file
luigirodriguez_reading/bookshelf/views.py
View file @
f434234e
...
@@ -4,7 +4,8 @@ from django.views.generic.list import ListView
...
@@ -4,7 +4,8 @@ from django.views.generic.list import ListView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.urls
import
reverse_lazy
from
.models
import
Author
,
Books
from
.models
import
Author
,
Books
from
.forms
import
AuthorForm
,
BookForm
from
.forms
import
AuthorForm
,
BookForm
...
@@ -32,7 +33,7 @@ class AuthorsCreateView(CreateView):
...
@@ -32,7 +33,7 @@ class AuthorsCreateView(CreateView):
class
AuthorsUpdateView
(
UpdateView
):
class
AuthorsUpdateView
(
UpdateView
):
model
=
Author
model
=
Author
fields
=
'__all__'
fields
=
'__all__'
template_name
=
'bookshelf/
authors_details
.html'
template_name
=
'bookshelf/
edit-author
.html'
class
BooksListView
(
ListView
):
class
BooksListView
(
ListView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
...
@@ -53,8 +54,15 @@ class BooksCreateView(CreateView):
...
@@ -53,8 +54,15 @@ class BooksCreateView(CreateView):
class
BooksUpdateView
(
UpdateView
):
class
BooksUpdateView
(
UpdateView
):
model
=
Books
model
=
Books
fields
=
'__all__'
fields
=
'__all__'
template_name
=
'bookshelf/
book_details
.html'
template_name
=
'bookshelf/
edit-book
.html'
def
edit_author
(
request
,
id
):
author
=
get_object_or_404
(
Author
,
id
=
id
)
if
request
.
method
==
'GET'
:
return
render
(
request
,
'bookshelf/edit-author.html'
,
{
'form'
:
AuthorForm
(
instance
=
author
),
'id'
:
id
})
'''
def author_view(request):
def author_view(request):
if request.method == 'POST':
if request.method == 'POST':
form = AuthorForm(request.POST)
form = AuthorForm(request.POST)
...
@@ -63,7 +71,7 @@ def author_view(request):
...
@@ -63,7 +71,7 @@ def author_view(request):
return redirect(AuthorsDetailView, pk=new_author.pk)
return redirect(AuthorsDetailView, pk=new_author.pk)
else:
else:
form = AuthorForm()
form = AuthorForm()
return
render
(
request
,
'
add
-author.html'
,
{
'form'
:
form
})
return render(request, '
edit
-author.html', {'form': form})
def book_view(request):
def book_view(request):
if request.method == 'POST':
if request.method == 'POST':
...
@@ -73,4 +81,5 @@ def book_view(request):
...
@@ -73,4 +81,5 @@ def book_view(request):
return redirect(AuthorsDetailView, pk=new_author.pk)
return redirect(AuthorsDetailView, pk=new_author.pk)
else:
else:
form = AuthorForm()
form = AuthorForm()
return
render
(
request
,
'add-book.html'
,
{
'form'
:
form
})
return render(request, 'edit-book.html', {'form': form})
\ No newline at end of file
'''
\ No newline at end of file
luigirodriguez_reading/db.sqlite3
View file @
f434234e
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