Commit 91a06345 authored by Eury See's avatar Eury See

Updated Homepage and added New Book Page and New Author Page.

parent 494ccdd8
......@@ -2,4 +2,4 @@ Eurydice Gabrielle Madison Ong See, 204656, CSCI 40-F
Lab 03: My Favorite Books and Authors
March 28, 2023
This project was fully and truthfully accomplished by the individual whose name is indicated in the aforementioned.
<sgd> Eurydice Gabrielle Madison Ong See, March 28, 2023
\ No newline at end of file
<sgd> Eurydice Gabrielle Madison Ong See, March 30, 2023
\ No newline at end of file
{% extends 'bookshelf/base.html' %}
{% load static %}
{% block title %} Add New Author {% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'styles.css' %"}>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Add Author</button>
</form>
{% block styles %}
<style>
body {
background-color: #FEC98F ;
font-family: Georgia, serif;
font-size: 16px;
font-weight: bold;
color: #d87847;
}
</style>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'bookshelf/base.html' %}
{% load static %}
{% block title %} Add New Book {% endblock %}
{% block content %}
<link rel="stylesheet" href="{% static 'styles.css' %"}>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Add Book</button>
</form>
{% block styles %}
<style>
body {
background-color: #FEA8A5;
font-family: Georgia, serif;
font-size: 16px;
font-weight: bold;
color:#c35c5a;
}
</style>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
......@@ -11,6 +11,7 @@
<p>I enjoy reading books that range from genres including crime, thriller, magical realism, and historical fiction. Some of my favorite authors are Haruki Murakami and Dan Brown.</p>
<p><a href="http://127.0.0.1:8000/bookshelf/books">Books</a> <a href="http://127.0.0.1:8000/bookshelf/authors">Authors</a></p>
<p><a href="http://127.0.0.1:8000/bookshelf/books/add">Add Book</a> <a href="http://127.0.0.1:8000/bookshelf/authors/add">Add Author</a></p>
</div>
......
from django.urls import path
from .views import (BooksListView,BooksDetailView, AuthorListView, AuthorDetailView)
from .views import (
BooksListView,BooksDetailView, AuthorListView,
AuthorDetailView, AddBooksView, AddAuthorsView)
# EditBooksView, EditAuthorsView
from . import views
urlpatterns = [
......@@ -8,6 +11,10 @@ urlpatterns = [
path("books/<int:pk>/details", BooksDetailView.as_view(), name = "books-detail"),
path("authors", AuthorListView.as_view(), name = "authors"),
path("authors/<int:pk>/details", AuthorDetailView.as_view(), name = "author-detail"),
path("books/add/", AddBooksView.as_view(), name = "add-book"),
path("authors/add/", AddAuthorsView.as_view(), name = "add-author"),
# path("books/<int:pk>/edit/", EditBooksView.as_view(), name = "edit-book"),
# path("authors/<int:pk>/edit/", EditAuthorsView.as_view(), name = "edit-author"),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -2,6 +2,8 @@ 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
from django.views.generic.edit import UpdateView
from .models import Books, Author
......@@ -36,3 +38,22 @@ class AuthorDetailView(DetailView):
context['books'] = self.object.books
return context
class AddBooksView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class AddAuthorsView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
# class EditBooksView(UpdateView):
# model = Author
# fields = '__all__'
# template_name = 'bookshelf/edit-book.html'
# class EditAuthorsView(UpdateView):
# 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