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 @@
<form id='addAuthor' method="post">
{% csrf_token %}
{{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">
</form>
......
......@@ -23,6 +23,7 @@
<a class="navBtn" href="/home">Home</a>
<a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors">Authors</a>
<a class="navBtn" href="../edit/">Edit Author</a>
</div>
</div>
{% endblock %}
......@@ -8,7 +8,7 @@
<b>Author:</b> <a href="/authors/{{object.get_absolute_url}}/details/">{{ object.author }}</a> <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>Blurb:</b> {{ object.blurb}} <br>
......@@ -19,5 +19,6 @@
<a class="navBtn" href="/home">Home</a>
<a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors">Authors</a>
<a class="navBtn" href="../edit/">Edit book</a>
{% 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 @@
<div>
<a class="navBtn" href="/books">Books</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="/authors/add">Add Author</a>
</div>
......
# bookshelf/urls.py
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
urlpatterns = [
path('home/', homeView, name='home'),
path('books/', BooksView.as_view(), name="books"),
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/<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('authors/add', AuthorAddView.as_view(), name='add_author'),
]
......
......@@ -40,8 +40,11 @@ class BooksDetail(DetailView):
class BooksEdit(UpdateView):
model = Book
fields="__all__"
template_name = "bookshelf/edit-book.html"
success_url = "../details"
class AuthorView(ListView):
model=Author
......@@ -71,4 +74,7 @@ class AuthorDetail(DetailView):
class AuthorEdit(UpdateView):
model=Author
fields="__all__"
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