Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise ValidationError("Content summary progress out of range (0-1)")
super(ContentSummaryLog, self).save(*args, **kwargs)
class UserSessionLog(BaseLogModel):
"""
This model provides a record of a user session in Kolibri.
"""
# Morango syncing settings
morango_model_name = "usersessionlog"
user = models.ForeignKey(FacilityUser)
channels = models.TextField(blank=True)
start_timestamp = DateTimeTzField(default=local_now)
last_interaction_timestamp = DateTimeTzField(null=True, blank=True)
pages = models.TextField(blank=True)
@classmethod
def update_log(cls, user):
"""
Update the current UserSessionLog for a particular user.
"""
if user and isinstance(user, FacilityUser):
try:
user_session_log = cls.objects.filter(user=user).latest(
"last_interaction_timestamp"
)
except ObjectDoesNotExist:
user_session_log = None
for model in Model.objects.all():
model.save()
except OperationalError:
pass
class Migration(migrations.Migration):
dependencies = [
('kolibriauth', '0002_auto_20170608_2125'),
]
operations = [
migrations.AlterField(
model_name='deviceowner',
name='date_joined',
field=kolibri.core.fields.DateTimeTzField(default=kolibri.utils.time_utils.local_now, editable=False, verbose_name='date joined'),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="DeviceOwner")),
migrations.AlterField(
model_name='facilityuser',
name='date_joined',
field=kolibri.core.fields.DateTimeTzField(default=kolibri.utils.time_utils.local_now, editable=False, verbose_name='date joined'),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="FacilityUser")),
]
("user_id", morango.models.UUIDField()),
("classroom_id", morango.models.UUIDField()),
("contentnode_id", morango.models.UUIDField(null=True)),
("lesson_id", morango.models.UUIDField(null=True)),
("quiz_id", morango.models.UUIDField(null=True)),
(
"reason",
models.CharField(
blank=True,
choices=[("Multiple", "MultipleUnsuccessfulAttempts")],
max_length=200,
),
),
(
"timestamp",
kolibri.core.fields.DateTimeTzField(
default=kolibri.utils.time_utils.local_now
),
from __future__ import unicode_literals
from django.db import migrations
import kolibri.core.fields
class Migration(migrations.Migration):
dependencies = [("content", "0001_initial")]
operations = [
migrations.AddField(
model_name="channelmetadatacache",
name="last_updated",
field=kolibri.core.fields.DateTimeTzField(null=True),
)
from rest_framework.serializers import set_value
from rest_framework.settings import api_settings
from .fields import DateTimeTzField as DjangoDateTimeTzField
class DateTimeTzField(DateTimeField):
def to_internal_value(self, data):
data = super(DateTimeTzField, self).to_internal_value(data)
tz = timezone.get_current_timezone()
if not data.tzinfo:
data = timezone.make_aware(data, pytz.utc)
return data.astimezone(tz)
serializer_field_mapping = {DjangoDateTimeTzField: DateTimeTzField}
serializer_field_mapping.update(ModelSerializer.serializer_field_mapping)
class KolibriModelSerializer(ModelSerializer):
serializer_field_mapping = serializer_field_mapping
def run_validation(self, data=empty):
"""
We override the default `run_validation`, because the validation
performed by validators and the `.validate()` method should
be coerced into an error dictionary with a 'non_fields_error' key.
"""
(is_empty_value, data) = self.validate_empty_values(data)
migrations.CreateModel(
name="NotificationsLog",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("coach_id", morango.models.UUIDField()),
(
"timestamp",
kolibri.core.fields.DateTimeTzField(
default=kolibri.utils.time_utils.local_now
),
("number_of_assessments", models.IntegerField()),
("mastery_model", kolibri.core.fields.JSONField(default={})),
("randomize", models.BooleanField(default=False)),
("is_manipulable", models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name="ChannelMetadata",
fields=[
("id", morango.models.UUIDField(primary_key=True, serialize=False)),
("name", models.CharField(max_length=200)),
("description", models.CharField(blank=True, max_length=400)),
("author", models.CharField(blank=True, max_length=400)),
("version", models.IntegerField(default=0)),
("thumbnail", models.TextField(blank=True)),
("last_updated", kolibri.core.fields.DateTimeTzField(null=True)),
("min_schema_version", models.CharField(max_length=50)),
],
),
migrations.CreateModel(
name="ContentNode",
fields=[
("id", morango.models.UUIDField(primary_key=True, serialize=False)),
("title", models.CharField(max_length=200)),
("content_id", morango.models.UUIDField(db_index=True)),
("channel_id", morango.models.UUIDField(db_index=True)),
(
"description",
models.CharField(blank=True, max_length=400, null=True),
),
("sort_order", models.FloatField(blank=True, null=True)),
("license_owner", models.CharField(blank=True, max_length=200)),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="ExamLog")),
migrations.AlterField(
model_name='masterylog',
name='completion_timestamp',
field=kolibri.core.fields.DateTimeTzField(blank=True, null=True),
),
migrations.AlterField(
model_name='masterylog',
name='end_timestamp',
field=kolibri.core.fields.DateTimeTzField(blank=True, null=True),
),
migrations.AlterField(
model_name='masterylog',
name='start_timestamp',
field=kolibri.core.fields.DateTimeTzField(),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="MasteryLog")),
migrations.AlterField(
model_name='usersessionlog',
name='last_interaction_timestamp',
field=kolibri.core.fields.DateTimeTzField(null=True),
),
migrations.AlterField(
model_name='usersessionlog',
name='start_timestamp',
field=kolibri.core.fields.DateTimeTzField(default=kolibri.utils.time_utils.local_now),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="UserSessionLog")),
]
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="AttemptLog")),
migrations.AlterField(
model_name='contentsessionlog',
name='end_timestamp',
field=kolibri.core.fields.DateTimeTzField(blank=True, null=True),
),
migrations.AlterField(
model_name='contentsessionlog',
name='start_timestamp',
field=kolibri.core.fields.DateTimeTzField(),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="ContentSessionLog")),
migrations.AlterField(
model_name='contentsummarylog',
name='completion_timestamp',
field=kolibri.core.fields.DateTimeTzField(blank=True, null=True),
),
migrations.AlterField(
model_name='contentsummarylog',
name='end_timestamp',
field=kolibri.core.fields.DateTimeTzField(blank=True, null=True),
),
migrations.AlterField(
model_name='contentsummarylog',
name='start_timestamp',
field=kolibri.core.fields.DateTimeTzField(),
),
migrations.RunPython(partial(convert_datetime_to_datetimetz, model_name="ContentSummaryLog")),
migrations.AlterField(
model_name='examattemptlog',
name='completion_timestamp',
field=kolibri.core.fields.DateTimeTzField(blank=True, null=True),