Commit fd327cc3 authored by Caryn Lopez-Go's avatar Caryn Lopez-Go

updated bookshelf with new update and add buttons

parent 02bd157e
Lopez-Go, Caryn Bryne C. (213558)
CSCI 40 C
Lab 3: My Favorite Books and Authors
March 28, 2023
Lab 04: My Favorite Books and Authors v2
April 25, 2023
This lab was made by me and only me.
<sgd> Caryn Bryne C. Lopez-Go, March 27, 2023
\ No newline at end of file
<sgd> Caryn Bryne C. Lopez-Go, April 25, 2023
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="SUBMIT" value="Add Author">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="SUBMIT" value="Add Book">
</form>
{% endblock %}
\ No newline at end of file
......@@ -16,6 +16,7 @@
{% endfor %}
</ul>
<section class="bottom">
<a href="{% url 'bookshelf:edit-author' author.id %}">Edit Author</a><br>
<a href="{% url 'bookshelf:home' %}">Home</a>
<a href="{% url 'bookshelf:books' %}">Books</a>
<a href="{% url 'bookshelf:authors' %}">Authors</a>
......
......@@ -10,6 +10,7 @@
{{ books.blurb }}<br>
</p>
<section class="bottom">
<a href="{% url 'bookshelf:edit-book' books.id %}">Edit Book</a><br>
<a href="{% url 'bookshelf:home' %}">Home</a>
<a href="{% url 'bookshelf:books' %}">Books</a>
<a href="{% url 'bookshelf:authors' %}">Authors</a>
......
{% extends 'base.html' %}
{% block title %}Edit Author{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="SUBMIT" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Edit Book{% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<input type="SUBMIT" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
......@@ -6,6 +6,8 @@
<section class="bottom">
<a href="{% url 'bookshelf:books' %}">Books</a>
<a href="{% url 'bookshelf:authors' %}">Authors</a>
<a href="{% url 'bookshelf:add-book' %}">Add Book</a>
<a href="{% url 'bookshelf:add-author' %}">Add Author</a>
</section>
{% endblock %}
\ No newline at end of file
......@@ -7,7 +7,11 @@ urlpatterns = [
path('authors/', AuthorsListView.as_view(), name = "authors"),
path('authors/<int:pk>/details', AuthorDetailsView.as_view(), name = "author-details"),
path('books/', BooksListView.as_view(), name = "books"),
path('books/<int:pk>/details', BookDetailsView.as_view(), name = "book-details")
path('books/<int:pk>/details', BookDetailsView.as_view(), name = "book-details"),
path('books/add/', BookCreateView.as_view(), name="add-book"),
path('authors/add/', AuthorCreateView.as_view(), name="add-author"),
path('books/<int:pk>/edit/', BookUpdateView.as_view(), name="edit-book"),
path('authors/<int:pk>/edit/', AuthorUpdateView.as_view(), name="edit-author"),
]
app_name = 'bookshelf'
\ No newline at end of file
......@@ -4,11 +4,13 @@ from django.http import HttpResponse
from .models import Author, Books
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
# Create your views here.
def home(request):
return render(request, 'bookshelf/home.html')
#Books
class BooksListView(ListView):
model = Books
template_name = 'bookshelf/books.html'
......@@ -17,10 +19,31 @@ class BookDetailsView(DetailView):
model = Books
template_name = 'bookshelf/book_details.html'
class BookCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class BookUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
#Authors
class AuthorsListView(ListView):
model = Author
template_name = 'bookshelf/authors.html'
class AuthorDetailsView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
\ No newline at end of file
template_name = 'bookshelf/author_details.html'
class AuthorCreateView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
class AuthorUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
\ No newline at end of file
No preview for this file type
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