Commit e3dc6a99 authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

front end of add-book.html is done

parent d8309378
...@@ -31,4 +31,7 @@ class Book(models.Model): ...@@ -31,4 +31,7 @@ class Book(models.Model):
return self.title return self.title
def get_absolute_url(self): def get_absolute_url(self):
return self.pk return self.pk
\ No newline at end of file
def getYearPublished(self):
return self.year_published.year
\ No newline at end of file
{% extends 'base.html '%}
{% block title %} Add new Author {% endblock %}
{% block content %}
<form action="/" method="post">
{% csrf_token %}
<label for="title">Title:</label>
<input type="text" id="textField" name="title"><br><br>
<label for="author">Author:</label>
<select id="selectField" name='author'>
{% for author in object_list %}
<option value={{ author }}>{{ author }}</option>
{% endfor %}
</select>
<label for="publisher">Publisher:</label>
<input type="text" id="textField" name="publisher"><br><br>
<label for="yearPublished">Year published:</label>
<input type="date" id="dateField" name="yearPublished"><br><br>
<label for="ISBN">ISBN:</label>
<input type="text" id="textField" name="ISBN"><br><br>
<label for="blurb">Blurb:</label>
<input type="text" id="textField" name="blurb"><br><br>
<input type="submit" id="submitButton" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html '%}
{% block title %} Add new book {% endblock %}
{% block content %}
<form action="/" method="post">
{% csrf_token %}
<label for="title">Title:</label>
<input type="text" id="textField" name="title"><br><br>
<label for="author">Author:</label>
<select id="selectField" name='author'>
{% for author in object_list %}
<option value={{ author }}>{{ author }}</option>
{% endfor %}
</select>
<label for="publisher">Publisher:</label>
<input type="text" id="textField" name="publisher"><br><br>
<label for="yearPublished">Year published:</label>
<input type="date" id="dateField" name="yearPublished"><br><br>
<label for="ISBN">ISBN:</label>
<input type="text" id="textField" name="ISBN"><br><br>
<label for="blurb">Blurb:</label>
<input type="text" id="textField" name="blurb"><br><br>
<input type="submit" id="submitButton" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
{% block additional %} Welcome to Neptune's database of favorite books and authors {% endblock %} {% block additional %} Welcome to Neptune's database of favorite books and authors {% endblock %}
{% block content %} {% block content %}
<p>My taste in books are very random and usually done in the spur of the moment. I cannot commit to a series. </p> <p> My taste in books are very random and usually done in the spur of the moment. I cannot commit to a series. </p>
<div> <div>
<a class="navBtn" href="/books">Books</a> <a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors"> Authors</a> <a class="navBtn" href="/authors"> Authors</a>
<br>
<a class="navBtn" href="/books/add">Add Book</a>
<!--<a class="navBtn" href="/authors">Add Author</a>-->
</div> </div>
{% endblock %} {% endblock %}
# bookshelf/urls.py # bookshelf/urls.py
from django.urls import path from django.urls import path
from .views import (homeView, BooksView, BooksDetail, AuthorView, AuthorDetail) from .views import (homeView, BooksView, BooksAddView, BooksDetail, AuthorView, AuthorDetail)
from django.conf.urls.static import static from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
...@@ -9,6 +9,9 @@ urlpatterns = [ ...@@ -9,6 +9,9 @@ urlpatterns = [
path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"), path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"),
path('authors/', AuthorView.as_view(), name="authors"), path('authors/', AuthorView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"), path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"),
#path for the forms that add
path('books/add', BooksAddView.as_view(), name='add_books'),
#path('authors/add'),
] ]
# This might be needed, depending on your Django version # This might be needed, depending on your Django version
......
...@@ -12,6 +12,11 @@ class BooksView(ListView): ...@@ -12,6 +12,11 @@ class BooksView(ListView):
template_name = "bookshelf/books.html" template_name = "bookshelf/books.html"
class BooksAddView(ListView):
model = Author
template_name = "bookshelf/add-book.html"
class BooksDetail(DetailView): class BooksDetail(DetailView):
model = Book model = Book
template_name = "bookshelf/book_detais.html" template_name = "bookshelf/book_detais.html"
...@@ -20,6 +25,10 @@ class BooksDetail(DetailView): ...@@ -20,6 +25,10 @@ class BooksDetail(DetailView):
class AuthorView(ListView): class AuthorView(ListView):
model=Author model=Author
template_name = "bookshelf/authors.html" template_name = "bookshelf/authors.html"
class AuthorAddView(ListView):
model = Book
template_name = "bookshelf/add-author.html"
class AuthorDetail(DetailView): class AuthorDetail(DetailView):
......
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