Commit 2e1e5435 authored by Ysobel Vera's avatar Ysobel Vera

edited views.py, author_details, book_detais, edit-author, and edit-book files

+edited views.py to add the url for the BookUpdateView and AuthorUpdateView classes
+added an edit button to author_details and book_detais that redirects to the corresponding edit page
+edited edit-author and edit-book files to format according to project specs.
parent b39811d6
......@@ -14,7 +14,11 @@
<a href="/books/{{ book.get_absolute_url }}/details/"> {{ book.title }}</a>
</li>
{% endfor %}
<br><br>
<br>
<a href = "../edit/">
<input type="submit" value="Edit Author">
</a>
<br>
<a href="/home">Home</a>
<a href="/books">Books</a>
</div>
......
......@@ -8,7 +8,11 @@
Year Published: {{ object.year_published }}<br>
ISBN: {{ object.ISBN }}<br>
Blurb: {{ object.blurb }}<br></p>
<br><br>
<br>
<a href = "../edit/">
<input type="submit" value="Edit Book">
</a>
<br>
<a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a>
......
......@@ -17,6 +17,6 @@
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Edit Author">
<input type="submit" value="Save Changes">
</form>
{% endblock %}
......@@ -17,6 +17,6 @@
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Edit Book">
<input type="submit" value="Save Changes">
</form>
{% endblock %}
......@@ -36,7 +36,7 @@ class BookCreateView(CreateView):
if form.is_valid():
new_book = form.save()
redirect_url = "../" + new_book.get_absolute_url() +"/details/"
url = "../" + new_book.get_absolute_url() +"/details/"
return HttpResponseRedirect(redirect_url)
else:
return render(request, self.template_name, {'form': form})
......@@ -51,7 +51,7 @@ class AuthorCreateView(CreateView):
if form.is_valid():
new_author = form.save()
redirect_url = "../" + new_author.get_absolute_url() + "/details/"
url = "../" + new_author.get_absolute_url() + "/details/"
return HttpResponseRedirect(redirect_url)
else:
return render(request, self.template_name, {'form': form})
......@@ -61,9 +61,13 @@ class BookUpdateView(UpdateView):
fields = '__all__'
template_name = "bookshelf/edit-book.html"
success_url = "../details"
class AuthorUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = "bookshelf/edit-author.html"
success_url = "../details"
\ 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