Commit 5a3fd42b authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

edit-book.html and edit-author.html works

parent 8c74acea
...@@ -9,21 +9,6 @@ ...@@ -9,21 +9,6 @@
<form id='addAuthor' method="post"> <form id='addAuthor' method="post">
{% csrf_token %} {% csrf_token %}
{{form.as_p}} {{form.as_p}}
<!--<label for="firstName">First name:</label>
<input type="text" id="textField" name="firstName"><br><br>
<label for="lastName">Last name:</label>
<input type="text" id="textField" name="lastName"><br><br>
<label for="age">Age:</label>
<input type="number" id="textField" name="age"><br><br>
<label for="publisher">Publisher:</label>
<input type="text" id="textField" name="publisher"><br><br>
<label for="yearPublished">Year published:</label>
<input type="date" id="dateField" name="yearPublished"><br><br>
<label for="ISBN">ISBN:</label>
<input type="text" id="textField" name="ISBN"><br><br>
<label for="blurb">Blurb:</label>
<textarea name="blurb" form='addBook' rows=50 cols=50></textarea>
<input type="text" id="textField" name="blurb" ><br><br>-->
<input type="submit" id="submitButton" value="Add Author"> <input type="submit" id="submitButton" value="Add Author">
</form> </form>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<a class="navBtn" href="/home">Home</a> <a class="navBtn" href="/home">Home</a>
<a class="navBtn" href="/books">Books</a> <a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors">Authors</a> <a class="navBtn" href="/authors">Authors</a>
<a class="navBtn" href="../edit/">Edit Author</a>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<b>Author:</b> <a href="/authors/{{object.get_absolute_url}}/details/">{{ object.author }}</a> <br> <b>Author:</b> <a href="/authors/{{object.get_absolute_url}}/details/">{{ object.author }}</a> <br>
<b>Publisher:</b> {{ object.publisher}} <br> <b>Publisher:</b> {{ object.publisher}} <br>
<b>Year published:</b> {{ object.year_published}} <br> <b>Year published:</b> {{ object.getYearPublished}} <br>
<b>ISBN:</b> {{ object.ISBN}} <br> <b>ISBN:</b> {{ object.ISBN}} <br>
<b>Blurb:</b> {{ object.blurb}} <br> <b>Blurb:</b> {{ object.blurb}} <br>
...@@ -19,5 +19,6 @@ ...@@ -19,5 +19,6 @@
<a class="navBtn" href="/home">Home</a> <a class="navBtn" href="/home">Home</a>
<a class="navBtn" href="/books">Books</a> <a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors">Authors</a> <a class="navBtn" href="/authors">Authors</a>
<a class="navBtn" href="../edit/">Edit book</a>
{% endblock %} {% endblock %}
{% extends 'base.html' %}
{% block title %} Edit Author {% endblock %}
{% block additional %} Edit Author {% endblock %}
{% block content %}
<form id='addAuthor' method="post">
{% csrf_token %}
{{form.as_p}}
<input type="submit" id="submitButton" value="Edit Author">
</form>
{% endblock %}
{% extends 'base.html '%}
{% block title %} Edit Book {% endblock %}
{% block additional %} Edit Book {% endblock %}
{% block content %}
<form id="addBook" method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" id="submitButton" value="Submit">
</form>
{% endblock %}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<div> <div>
<a class="navBtn" href="/books">Books</a> <a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors"> Authors</a> <a class="navBtn" href="/authors"> Authors</a>
<br> <br><br><br>
<a class="navBtn" href="/books/add">Add Book</a> <a class="navBtn" href="/books/add">Add Book</a>
<a class="navBtn" href="/authors/add">Add Author</a> <a class="navBtn" href="/authors/add">Add Author</a>
</div> </div>
......
# bookshelf/urls.py # bookshelf/urls.py
from django.urls import path from django.urls import path
from .views import (homeView, BooksView, BooksAddView, BooksDetail, AuthorView, AuthorAddView, AuthorDetail) from .views import (homeView, BooksView, BooksAddView, BooksDetail, BooksEdit, AuthorView, AuthorAddView, AuthorDetail, AuthorEdit )
from django.conf.urls.static import static from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
path('home/', homeView, name='home'), path('home/', homeView, name='home'),
path('books/', BooksView.as_view(), name="books"), path('books/', BooksView.as_view(), name="books"),
path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"), path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"),
path('books/<int:pk>/edit/', BooksEdit.as_view(), name="book_edit"),
path('authors/', AuthorView.as_view(), name="authors"), path('authors/', AuthorView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"), path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"),
#path for the forms that add path('authors/<int:pk>/edit/', AuthorEdit.as_view(), name="author_edit"),
path('books/add', BooksAddView.as_view(), name='add_books'), path('books/add', BooksAddView.as_view(), name='add_books'),
path('authors/add', AuthorAddView.as_view(), name='add_author'), path('authors/add', AuthorAddView.as_view(), name='add_author'),
] ]
......
...@@ -40,8 +40,11 @@ class BooksDetail(DetailView): ...@@ -40,8 +40,11 @@ class BooksDetail(DetailView):
class BooksEdit(UpdateView): class BooksEdit(UpdateView):
model = Book model = Book
fields="__all__"
template_name = "bookshelf/edit-book.html" template_name = "bookshelf/edit-book.html"
success_url = "../details"
class AuthorView(ListView): class AuthorView(ListView):
model=Author model=Author
...@@ -71,4 +74,7 @@ class AuthorDetail(DetailView): ...@@ -71,4 +74,7 @@ class AuthorDetail(DetailView):
class AuthorEdit(UpdateView): class AuthorEdit(UpdateView):
model=Author model=Author
fields="__all__"
template_name = "bookshelf/edit-author.html" template_name = "bookshelf/edit-author.html"
success_url = "../details"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment