Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
anchisilang_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
Anchilla Vera Marie Silang
anchisilang_reading
Commits
77a186e1
Commit
77a186e1
authored
Apr 29, 2023
by
Anchilla Vera Marie Silang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Create and Update Views and URLS
parent
41bdaeaa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
urls.cpython-38.pyc
...isilang_reading/bookshelf/__pycache__/urls.cpython-38.pyc
+0
-0
views.cpython-38.pyc
...silang_reading/bookshelf/__pycache__/views.cpython-38.pyc
+0
-0
urls.py
anchisilang_reading/bookshelf/urls.py
+6
-1
views.py
anchisilang_reading/bookshelf/views.py
+40
-2
No files found.
anchisilang_reading/bookshelf/__pycache__/urls.cpython-38.pyc
View file @
77a186e1
No preview for this file type
anchisilang_reading/bookshelf/__pycache__/views.cpython-38.pyc
View file @
77a186e1
No preview for this file type
anchisilang_reading/bookshelf/urls.py
View file @
77a186e1
...
@@ -2,7 +2,8 @@ from django.urls import path
...
@@ -2,7 +2,8 @@ from django.urls import path
from
.
import
views
from
.
import
views
from
.views
import
(
HomeViews
,
AuthorsDetailsViews
,
from
.views
import
(
HomeViews
,
AuthorsDetailsViews
,
AuthorsViews
,
BookDetailsViews
,
AuthorsViews
,
BookDetailsViews
,
BooksViews
)
BooksViews
,
BookCreate
,
AuthorCreate
,
BookUpdate
,
AuthorUpdate
)
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
views
.
HomeViews
,
name
=
'home'
),
path
(
'home/'
,
views
.
HomeViews
,
name
=
'home'
),
...
@@ -10,4 +11,8 @@ urlpatterns = [
...
@@ -10,4 +11,8 @@ urlpatterns = [
path
(
'books/'
,
BooksViews
.
as_view
(),
name
=
'books'
),
path
(
'books/'
,
BooksViews
.
as_view
(),
name
=
'books'
),
path
(
'authors/<int:pk>/details/'
,
AuthorsDetailsViews
.
as_view
(),
name
=
'authordetails'
),
path
(
'authors/<int:pk>/details/'
,
AuthorsDetailsViews
.
as_view
(),
name
=
'authordetails'
),
path
(
'books/<int:pk>/details/'
,
BookDetailsViews
.
as_view
(),
name
=
'bookdetails'
),
path
(
'books/<int:pk>/details/'
,
BookDetailsViews
.
as_view
(),
name
=
'bookdetails'
),
path
(
'books/add/'
,
BookCreate
.
as_view
(),
name
=
'booknew'
),
path
(
'books/<int:pk>/edit/'
,
BookUpdate
.
as_view
(),
name
=
'bookedit'
),
path
(
'authors/<int:pk>/edit/'
,
AuthorUpdate
.
as_view
(),
name
=
'authoredit'
),
path
(
'author/add/'
,
AuthorCreate
.
as_view
(),
name
=
'authornew'
),
]
]
anchisilang_reading/bookshelf/views.py
View file @
77a186e1
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic
import
ListView
,
DetailView
from
django.urls
import
reverse
from
django.views.generic
import
ListView
,
DetailView
,
CreateView
,
UpdateView
from
.models
import
*
from
.models
import
*
...
@@ -28,4 +29,41 @@ class AuthorsDetailsViews(DetailView):
...
@@ -28,4 +29,41 @@ class AuthorsDetailsViews(DetailView):
class
BookDetailsViews
(
DetailView
):
class
BookDetailsViews
(
DetailView
):
template_name
=
"book_details.html"
template_name
=
"book_details.html"
model
=
Book
model
=
Book
\ No newline at end of file
class
BookCreate
(
CreateView
):
template_name
=
"add-book.html"
model
=
Book
fields
=
'__all__'
def
get_success
(
self
):
return
reverse
(
'booknew'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
class
AuthorCreate
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
"add-author.html"
def
get_success
(
self
):
return
reverse
(
'authornew'
,
kwarg
=
{
'pk'
:
self
.
object
.
id
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
class
BookUpdate
(
UpdateView
):
model
=
Book
template_name
=
"edit-book.html"
fields
=
'__all__'
def
get_success_url
(
self
):
return
reverse
(
'bookdetails'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
class
AuthorUpdate
(
UpdateView
):
model
=
Author
template_name
=
"edit-author.html"
fields
=
'__all__'
def
get_success_url
(
self
):
return
reverse
(
'authordetails'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
},
current_app
=
self
.
request
.
resolver_match
.
namespace
)
\ 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