Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
1f8787c9
Commit
1f8787c9
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-113: Fixing wrong implementation of validate method
parent
2df393b1
No related branches found
No related tags found
1 merge request
!166
GREG-113 guest date of birth
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gregui/api/serializers/guest.py
+5
-3
5 additions, 3 deletions
gregui/api/serializers/guest.py
with
5 additions
and
3 deletions
gregui/api/serializers/guest.py
+
5
−
3
View file @
1f8787c9
...
...
@@ -61,17 +61,19 @@ class GuestRegisterSerializer(serializers.ModelSerializer):
return
instance
def
validate_date_of_birth
(
self
,
value
):
def
validate_date_of_birth
(
self
,
date_of_birth
):
today
=
datetime
.
date
.
today
()
# Check that the date of birth is between the interval starting about 100 years ago and last year
if
(
not
today
-
datetime
.
timedelta
(
weeks
=
100
*
52
)
<
value
<
today
-
datetime
.
timedelta
(
weeks
=
52
)
<
date_of_birth
<
today
-
datetime
.
timedelta
(
weeks
=
52
)
):
raise
serializers
.
ValidationError
(
"
Invalid date of birth
"
)
return
date_of_birth
class
Meta
:
model
=
Person
fields
=
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment