Commit d93d3a6e authored by Nics De Vega's avatar Nics De Vega

Created edit pages for books and authors

parent afc77108
......@@ -5,10 +5,10 @@ from .models import Book, Author
class BookForm(forms.ModelForm):
class Meta:
model = Book
fields = ['Title', 'Author', 'Publisher','Year Published','ISBN','Blurb']
fields = '__all__'
class AuthorForm(forms.ModelForm):
class Meta:
model = Author
fields = ['First Name', 'Last Name', 'Age','Nationality','Bio']
fields = '__all__'
......@@ -3,7 +3,7 @@
{% block title %}Add New Author{% endblock %}
{% block content %}
<br>
<form action="authors/<int:pk>/details/" method="post">
<form method="post">
{% csrf_token %}
{% for field in form %}
{{field.label}}:{{field}} <br><br>
......
......@@ -3,11 +3,11 @@
{% block title %}Add New Book{% endblock %}
{% block content %}
<br>
<form action="books/<int:pk>/details/" method="post">
<form method="post">
{% csrf_token %}
{% for field in form %}
{{field.label}}:{{field}} <br><br>
{% endfor %}
<input type="submit" value="Add book">
<input type="submit" value="Add Book">
</form>
{% endblock %}
\ No newline at end of file
......@@ -8,6 +8,8 @@
<li class="list-group-item"><h4>{{object.age}}</h4></li>
<li class="list-group-item"><h4>{{object.nationality}}</h4></li>
<li class="list-group-item"><p>{{object.bio}}</p></li>
<li class="list-group-item"><a href="/bookshelf/authors/{{object.pk}}/edit">Edit Author</a></li>
<li class="list-group-item"><h3>Books by {{object.first_name}} {{object.last_name}} I love:</h3></li>
<li class="list-group-item">
<ul>
......
......@@ -10,6 +10,9 @@
<li class="list-group-item"><h4>{{object.year_published}}</h4></li>
<li class="list-group-item"><h4>{{object.ISBN}}</h4></li>
<li class="list-group-item"><p>{{object.blurb}}</p></li>
<li class="list-group-item"><a href="/bookshelf/books/{{object.pk}}/edit">Edit Book</a></li>
<li class="list-group-item">
<h2 class="text-center">
<small>
......@@ -20,4 +23,4 @@
</h2>
</li>
</ul>
{% endblock %}
\ No newline at end of file
{% endblock %}]
\ No newline at end of file
......@@ -3,12 +3,11 @@
{% block title %}Edit Author{% endblock %}
{% block content %}
<br>
<form action="/" method="post">
<form method="post">
{% csrf_token %}
{% for field in form %}
{{field.label}}:{{field}} <br><br>
{% endfor %}
<input type="submit" value="Submit">
<input type="submit" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
......@@ -3,12 +3,11 @@
{% block title %}Edit Book{% endblock %}
{% block content %}
<br>
<form action="/" method="post">
<form method="post">
{% csrf_token %}
{% for field in form %}
{{field.label}}:{{field}} <br><br>
{% endfor %}
<input type="submit" value="Submit">
<input type="submit" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
......@@ -11,13 +11,13 @@ urlpatterns = [
path('books/',BooksView.as_view(),name='books'),
path('books/<int:pk>/details/',BooksDetailView.as_view(),name='book_details'),
path('books/add/',BooksCreateView.as_view(),name='add_book'),
path('books/<int:pk>/edit/',BooksUpdateView.as_view(),name='update_book'),
path('books/add/',BooksCreateView.as_view(),name='add-book'),
path('books/<int:pk>/edit/',BooksUpdateView.as_view(),name='update-book'),
path('authors/',AuthorsView.as_view(),name='authors'),
path('authors/<int:pk>/details/',AuthorsDetailView.as_view(),name='author_details'),
path('authors/add/',AuthorsCreateView.as_view(),name='add_author'),
path('authors/<int:pk>/edit/',AuthorsUpdateView.as_view(),name='update_author'),
path('authors/add/',AuthorsCreateView.as_view(),name='add-author'),
path('authors/<int:pk>/edit/',AuthorsUpdateView.as_view(),name='update-author'),
]
......
......@@ -43,6 +43,6 @@ class AuthorsCreateView(CreateView):
template_name = "bookshelf/add-author.html"
class AuthorsUpdateView(UpdateView):
model = Book
model = Author
fields = '__all__'
template_name = "bookshelf/edit-author.html"
\ No newline at end of file
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