Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean Michel Rouly
bookshare
Commits
e2435e72
Commit
e2435e72
authored
May 01, 2015
by
Daniel W Bond
Browse files
validators pls :-(
parent
b81c9733
Changes
1
Hide whitespace changes
Inline
Side-by-side
bookshare/trades/models.py
View file @
e2435e72
...
...
@@ -47,8 +47,10 @@ class Listing(TimeStampedModel):
title
=
models
.
CharField
(
max_length
=
200
)
author
=
models
.
CharField
(
max_length
=
200
)
isbn
=
models
.
CharField
(
max_length
=
20
,
validators
=
[
RegexValidator
(
'^[0-9xX-]{10,20}'
,
message
=
'Please enter a valid ISBN.'
)])
validators
=
[
RegexValidator
(
regex
=
'^[0-9xX-]{10,20}'
,
message
=
'Please enter a valid ISBN.'
,
code
=
'invalid_isbn'
)])
year
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
# some professors may assign books still to be officially published
validators
=
[
MaxValueValidator
(
date
.
today
().
year
+
1
)])
...
...
@@ -61,8 +63,10 @@ class Listing(TimeStampedModel):
access_code
=
models
.
CharField
(
choices
=
ACCESS_CODE_CHOICES
,
max_length
=
30
,
default
=
NOT_APPLICABLE
)
course_abbr
=
models
.
CharField
(
max_length
=
10
,
blank
=
True
,
validators
=
[
RegexValidator
(
'^([a-zA-Z]){2,4} (\d){3}$'
,
message
=
'Please enter a valid course.'
)])
validators
=
[
RegexValidator
(
regex
=
'^([a-zA-Z]){2,4} (\d){3}$'
,
message
=
'Please enter a valid course.'
,
code
=
'invalid_course_abbr'
)])
description
=
models
.
TextField
(
blank
=
True
,
max_length
=
2000
)
price
=
models
.
PositiveIntegerField
(
default
=
0
,
validators
=
[
MaxValueValidator
(
1000
)])
...
...
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