Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nishaespera_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
Julia Anishka
nishaespera_reading
Commits
81fadb25
Commit
81fadb25
authored
Mar 27, 2023
by
Julia Anishka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added function to verify word count of blurb
parent
5f745c95
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
models.cpython-310.pyc
...pera_reading/bookshelf/__pycache__/models.cpython-310.pyc
+0
-0
0002_alter_books_blurb.py
...ra_reading/bookshelf/migrations/0002_alter_books_blurb.py
+19
-0
0002_alter_books_blurb.cpython-310.pyc
...ations/__pycache__/0002_alter_books_blurb.cpython-310.pyc
+0
-0
models.py
nishaespera_reading/bookshelf/models.py
+10
-3
db.sqlite3
nishaespera_reading/db.sqlite3
+0
-0
No files found.
nishaespera_reading/bookshelf/__pycache__/models.cpython-310.pyc
View file @
81fadb25
No preview for this file type
nishaespera_reading/bookshelf/migrations/0002_alter_books_blurb.py
0 → 100644
View file @
81fadb25
# Generated by Django 3.2 on 2023-03-27 10:08
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'books'
,
name
=
'blurb'
,
field
=
models
.
TextField
(
max_length
=
200
,
validators
=
[
django
.
core
.
validators
.
MinValueValidator
(
100
)]),
),
]
nishaespera_reading/bookshelf/migrations/__pycache__/0002_alter_books_blurb.cpython-310.pyc
0 → 100644
View file @
81fadb25
File added
nishaespera_reading/bookshelf/models.py
View file @
81fadb25
...
...
@@ -13,10 +13,17 @@ class Author(models.Model):
def
__str__
(
self
):
return
self
.
first_name
+
' '
+
self
.
last_name
def
verify_
int
(
value
):
def
verify_
ISBN
(
value
):
if
value
.
isdigit
()
==
False
:
raise
ValidationError
(
'ISBN must only be integers.'
)
def
verify_wordCount
(
value
):
word_count
=
len
(
value
.
split
())
if
word_count
<
100
:
raise
ValidationError
(
'Word count is less than 100. Required range is 100 to 200 words.'
)
if
word_count
>
200
:
raise
ValidationError
(
'Word count is more than 200. Required range is 100 to 200 words.'
)
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
70
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
...
...
@@ -24,8 +31,8 @@ class Books(models.Model):
year_published
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
validators
=
[
MinValueValidator
(
1000
),
MaxValueValidator
(
datetime
.
now
()
.
year
)]
)
ISBN
=
models
.
CharField
(
max_length
=
13
,
validators
=
[
MinValueValidator
(
13
),
verify_
int
])
blurb
=
models
.
TextField
(
max_length
=
200
,
validators
=
[
MinValueValidator
(
100
)
])
ISBN
=
models
.
CharField
(
max_length
=
13
,
validators
=
[
MinValueValidator
(
13
),
verify_
ISBN
])
blurb
=
models
.
TextField
(
validators
=
[
verify_wordCount
])
def
__str__
(
self
):
return
self
.
title
...
...
nishaespera_reading/db.sqlite3
View file @
81fadb25
No preview for this file type
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