Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Backend
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
swp-unisport
team-warumkeinrust
Backend
Commits
3edfe731
Commit
3edfe731
authored
3 years ago
by
borzechof99
Browse files
Options
Downloads
Patches
Plain Diff
Add proper validation docstrings and use the function where needed
parent
7e2ae09b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unisportomat/quiz/models.py
+3
-2
3 additions, 2 deletions
unisportomat/quiz/models.py
with
3 additions
and
2 deletions
unisportomat/quiz/models.py
+
3
−
2
View file @
3edfe731
...
@@ -6,7 +6,8 @@ from django.db import models
...
@@ -6,7 +6,8 @@ from django.db import models
def
validate_rating
(
value
):
def
validate_rating
(
value
):
"""
"""
TODO: Validations are only run when using Model Forms. Maybe do that, if there is time.
This Function acts as a Validator for Ratings.
Sadly, it isn
'
t called automatically, so it needs to be used manually.
"""
"""
if
not
((
10
>=
value
>=
1
)
or
value
==
-
1
):
if
not
((
10
>=
value
>=
1
)
or
value
==
-
1
):
...
@@ -71,7 +72,7 @@ class Sport(models.Model):
...
@@ -71,7 +72,7 @@ class Sport(models.Model):
rating_obj
,
_
=
CriterionRating
.
objects
.
get_or_create
(
rating_obj
,
_
=
CriterionRating
.
objects
.
get_or_create
(
sport
=
self
,
criterion
=
criterion
,
defaults
=
{
"
rating
"
:
rating
}
sport
=
self
,
criterion
=
criterion
,
defaults
=
{
"
rating
"
:
rating
}
)
)
rating_obj
.
rating
=
rating
rating_obj
.
rating
=
validate_rating
(
rating
)
rating_obj
.
save
()
rating_obj
.
save
()
return
rating_obj
return
rating_obj
...
...
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