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
a14b4d1f
Commit
a14b4d1f
authored
Mar 27, 2023
by
Julia Anishka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created new function to verify ISBN in models.py
parent
bb88e691
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
models.cpython-310.pyc
...pera_reading/bookshelf/__pycache__/models.cpython-310.pyc
+0
-0
models.py
nishaespera_reading/bookshelf/models.py
+4
-2
No files found.
nishaespera_reading/bookshelf/__pycache__/models.cpython-310.pyc
View file @
a14b4d1f
No preview for this file type
nishaespera_reading/bookshelf/models.py
View file @
a14b4d1f
...
@@ -13,9 +13,11 @@ class Author(models.Model):
...
@@ -13,9 +13,11 @@ class Author(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
first_name
+
' '
+
self
.
last_name
return
self
.
first_name
+
' '
+
self
.
last_name
def
verify_
int
(
value
):
def
verify_
ISBN
(
value
):
if
value
.
isdigit
()
==
False
:
if
value
.
isdigit
()
==
False
:
raise
ValidationError
(
'ISBN must only be integers.'
)
raise
ValidationError
(
'ISBN must only be integers.'
)
if
value
!=
13
:
raise
ValidationError
(
'ISBN must be a 13 digit number.'
)
def
verify_wordCount
(
value
):
def
verify_wordCount
(
value
):
word_count
=
int
(
len
(
value
.
split
()))
word_count
=
int
(
len
(
value
.
split
()))
...
@@ -31,7 +33,7 @@ class Books(models.Model):
...
@@ -31,7 +33,7 @@ class Books(models.Model):
year_published
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
year_published
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
validators
=
[
MinValueValidator
(
1000
),
MaxValueValidator
(
datetime
.
now
()
.
year
)]
validators
=
[
MinValueValidator
(
1000
),
MaxValueValidator
(
datetime
.
now
()
.
year
)]
)
)
ISBN
=
models
.
CharField
(
max_length
=
13
,
validators
=
[
MinValueValidator
(
13
),
verify_int
])
ISBN
=
models
.
CharField
(
validators
=
[
verify_ISBN
])
blurb
=
models
.
TextField
(
validators
=
[
verify_wordCount
])
blurb
=
models
.
TextField
(
validators
=
[
verify_wordCount
])
def
__str__
(
self
):
def
__str__
(
self
):
...
...
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