Commit d0e45f6a authored by Gabriel Limbaga's avatar Gabriel Limbaga

added add book/author and edit book/author according to specifications

parent 37caf373
Gabriel S. Limbaga, 213484, BS CS, CSCI40 - C
Lab 03 - My Favorite Books and Authors
March 28, 2023
Lab 04 - My Favorite Books and Authors v2
April 25, 2023
This lab was truthfully completed by me Gabriel Limbaga through the use of the materials provided in the canvas course
<sgd> Gabriel Limbaga, Mar 28, 2023
\ No newline at end of file
<sgd> Gabriel Limbaga, Apr 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,7 +16,7 @@
{% endfor %}
</ul>
<a href="/bookshelf/home/">Home</a>
<a href="/bookshelf/books/">Books</a>
<a href="/home/">Home</a>
<a href="/books/">Books</a>
{% endblock %}
\ No newline at end of file
......@@ -9,20 +9,22 @@ Age: {{object.age}} <br>
Nationality: {{object.nationality}} <br>
{{object.bio}} <br>
<a href="/authors/{{object.id}}/edit"><button>Edit Author</button></a><br>
Books by {{object}} I love:
<ul>
{% for books in object.books_set.all %}
<li>
<a href="/bookshelf/books/{{books.pk}}/details">{{books.title}}</a>
<a href="/books/{{books.pk}}/details">{{books.title}}</a>
</li>
{%endfor%}
</ul>
<a href="/bookshelf/home/">Home</a> &nbsp; &nbsp;
<a href="/bookshelf/books/">Books</a> &nbsp; &nbsp;
<a href="/bookshelf/authors/">Authors</a>
<a href="/home/">Home</a> &nbsp; &nbsp;
<a href="/books/">Books</a> &nbsp; &nbsp;
<a href="/authors/">Authors</a>
{% endblock %}
\ No newline at end of file
......@@ -16,7 +16,7 @@
{% endfor %}
</ul>
<a href="/bookshelf/home/">Home</a>&nbsp; &nbsp;
<a href="/bookshelf/authors/">Authors</a>
<a href="/home/">Home</a>&nbsp; &nbsp;
<a href="/authors/">Authors</a>
{% endblock %}
\ No newline at end of file
......@@ -10,10 +10,10 @@ Publisher: {{object.publisher}} <br>
Year Published: {{object.year_published}} <br>
ISBN: {{object.ISBN}} <br>
{{object.blurb}}<br>
<a href="/bookshelf/home/">Home</a>&nbsp; &nbsp;
<a href="/bookshelf/books/">Books</a>&nbsp; &nbsp;
<a href="/bookshelf/authors/">Authors</a>
<a href="/books/{{object.id}}/edit"><button>Edit Book</button></a><br>
<a href="/home/">Home</a>&nbsp; &nbsp;
<a href="/books/">Books</a>&nbsp; &nbsp;
<a href="/authors/">Authors</a>
{% endblock %}
\ No newline at end of file
{% 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
......@@ -10,6 +10,9 @@ into fictional worlds. The books by Rick Riordan and J.K. Rowling were among my
when I was little. As I grew up, books that had lessons I could use in real life such as the financial insight
given by Rich Dad, Poor Dad by Robert Kiyosaki really gave me more to think about as I started to get older.<br>
<a href="/bookshelf/books/">Books</a> &nbsp; &nbsp;
<a href="/bookshelf/authors/">Authors</a>
<a href="/books/">Books</a> &nbsp; &nbsp;
<a href="/authors/">Authors</a> <br>
<a href="/books/add/">Add Book</a> &nbsp; &nbsp;
<a href="/authors/add/">Add Author</a>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView
from .views import home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView, BookCreateView, BookUpdateView, AuthorCreateView, AuthorUpdateView
urlpatterns = [
path('home/', home, name="home"),
path('books/', BooksListView.as_view(), name="books-list"),
path('books/add/', BookCreateView.as_view(), name = "book-create" ),
path('books/<int:pk>/details/', BooksDetailView.as_view(), name="books-details"),
path('books/<int:pk>/edit/', BookUpdateView.as_view(), name = "book-edit" ),
path('authors/', AuthorListView.as_view(), name='author-list'),
path('authors/<int:pk>/details/', AuthorDetailView.as_view(), name="authors-details")
path('authors/add/', AuthorCreateView.as_view(), name='author-create'),
path('authors/<int:pk>/details/', AuthorDetailView.as_view(), name="authors-details"),
path('authors/<int:pk>/edit/', AuthorUpdateView.as_view(), name = "authors-edit" )
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -2,6 +2,7 @@ from django.shortcuts import render
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Books, Author
# Create your views here.
def home(request):
......@@ -22,3 +23,23 @@ class AuthorListView(ListView):
class AuthorDetailView(DetailView):
model = Author
template_name = "bookshelf/authors_detail.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"
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"
......@@ -17,6 +17,6 @@ from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('bookshelf/', include("bookshelf.urls")),
path('', include("bookshelf.urls")),
path('admin/', admin.site.urls),
]
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