Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
neptunesy_reading
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Star Neptune R. Sy
neptunesy_reading
Commits
8c74acea
Commit
8c74acea
authored
Apr 25, 2023
by
Star Neptune R. Sy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add-author is finally working
parent
38f32a2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
23 deletions
+48
-23
0005_alter_book_year_published.py
...ng/bookshelf/migrations/0005_alter_book_year_published.py
+19
-0
add-author.html
...esy_reading/bookshelf/templates/bookshelf/add-author.html
+6
-4
add-book.html
...unesy_reading/bookshelf/templates/bookshelf/add-book.html
+0
-17
views.py
neptunesy_reading/bookshelf/views.py
+23
-2
No files found.
neptunesy_reading/bookshelf/migrations/0005_alter_book_year_published.py
0 → 100644
View file @
8c74acea
# Generated by Django 3.2 on 2023-04-25 09:39
import
datetime
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0004_alter_book_year_published'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'book'
,
name
=
'year_published'
,
field
=
models
.
DateField
(
default
=
datetime
.
datetime
(
2023
,
4
,
25
,
17
,
39
,
19
,
682230
)),
),
]
neptunesy_reading/bookshelf/templates/bookshelf/add-author.html
View file @
8c74acea
...
...
@@ -6,9 +6,10 @@
{% block content %}
<form
id=
'add
Book'
action=
"/"
method=
"post"
>
<form
id=
'add
Author'
method=
"post"
>
{% csrf_token %}
<label
for=
"firstName"
>
First name:
</label>
{{form.as_p}}
<!--<label for="firstName">First name:</label>
<input type="text" id="textField" name="firstName"><br><br>
<label for="lastName">Last name:</label>
<input type="text" id="textField" name="lastName"><br><br>
...
...
@@ -22,8 +23,9 @@
<input type="text" id="textField" name="ISBN"><br><br>
<label for="blurb">Blurb:</label>
<textarea name="blurb" form='addBook' rows=50 cols=50></textarea>
<input
type=
"text"
id=
"textField"
name=
"blurb"
><br><br>
<input
type=
"submit"
id=
"submitButton"
value=
"Add
book
"
>
<input type="text" id="textField" name="blurb" ><br><br>
-->
<input
type=
"submit"
id=
"submitButton"
value=
"Add
Author
"
>
</form>
{% endblock %}
\ No newline at end of file
neptunesy_reading/bookshelf/templates/bookshelf/add-book.html
View file @
8c74acea
...
...
@@ -9,23 +9,6 @@
<form
id=
"addBook"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<!--<label for="title">Title:</label>
<input type="text" id="textField" name="title"><br><br>
<label for="author">Author:</label>
<select form="addBook" id="selectField" name='author'>
{% for author in object %}
<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>
<textarea form="addBook" name="blurb"></textarea>
<input type="text" id="textField" name="blurb"><br><br>-->
<input
type=
"submit"
id=
"submitButton"
value=
"Submit"
>
</form>
...
...
neptunesy_reading/bookshelf/views.py
View file @
8c74acea
...
...
@@ -29,7 +29,6 @@ class BooksAddView(CreateView):
blurb
=
request
.
POST
.
get
(
'blurb'
)
s
=
Book
(
title
=
title
,
author
=
Author
.
objects
.
get
(
pk
=
author
),
publisher
=
publisher
,
year_published
=
yearPublished
,
ISBN
=
ISBN
,
blurb
=
blurb
)
newUrl
=
s
.
save
()
return
HttpResponseRedirect
(
str
(
s
.
get_absolute_url
())
+
"/details/"
)
...
...
@@ -39,15 +38,37 @@ class BooksDetail(DetailView):
template_name
=
"bookshelf/book_detais.html"
class
BooksEdit
(
UpdateView
):
model
=
Book
template_name
=
"bookshelf/edit-book.html"
class
AuthorView
(
ListView
):
model
=
Author
template_name
=
"bookshelf/authors.html"
class
AuthorAddView
(
CreateView
):
model
=
Book
model
=
Author
fields
=
'__all__'
template_name
=
"bookshelf/add-author.html"
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
firstName
=
request
.
POST
.
get
(
'first_name'
)
lastName
=
request
.
POST
.
get
(
'last_name'
)
age
=
request
.
POST
.
get
(
'age'
)
nationality
=
request
.
POST
.
get
(
'nationality'
)
bio
=
request
.
POST
.
get
(
'bio'
)
newObject
=
Author
(
first_name
=
firstName
,
last_name
=
lastName
,
age
=
age
,
nationality
=
nationality
,
bio
=
bio
)
newObject
.
save
()
return
HttpResponseRedirect
(
str
(
newObject
.
get_absolute_url
())
+
"/details/"
)
class
AuthorDetail
(
DetailView
):
model
=
Author
template_name
=
"bookshelf/authors_details.html"
class
AuthorEdit
(
UpdateView
):
model
=
Author
template_name
=
"bookshelf/edit-author.html"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment