Disallow NaN value for speed key.

The VideoBlock `handle_ajax` is allowing NaN values for speed key
and causing videos to not load. Also added a data migration to fix
the data for learners.

PROD-1148
This commit is contained in:
Waheed Ahmed
2020-03-11 15:51:25 +05:00
parent 99a0da8ade
commit f54b9a42e7
3 changed files with 49 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ StudioViewHandlers are handlers for video descriptor instance.
import json
import logging
import math
import six
from django.core.files.base import ContentFile
@@ -89,6 +90,11 @@ class VideoStudentViewHandlers(object):
if key == 'bumper_last_view_date':
value = now()
if key == 'speed' and math.isnan(value):
message = u"Invalid speed value {}, must be a float.".format(value)
log.warning(message)
return json.dumps({'success': False, 'error': message})
setattr(self, key, value)
if key == 'speed':