Skip to content
Snippets Groups Projects
Commit 3edfe731 authored by borzechof99's avatar borzechof99 :whale2:
Browse files

Add proper validation docstrings and use the function where needed

parent 7e2ae09b
No related branches found
No related tags found
No related merge requests found
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment