# Path: bible/djangoforms.py
# class VerseField(models.Field):
#     description = "A scripture reference to a specific verse"
# 
#     def __init__(self, *args, **kwargs):
#         kwargs['max_length'] = 8
#         super(VerseField, self).__init__(*args, **kwargs)
# 
#     def db_type(self, connection):
#         return 'int(%s)' % self.max_length
# 
#     def get_prep_value(self, value):
#         return hash(value)
# 
#     # def from_db_value(self, value, expression, connection, context):
# 
#     def to_python(self, value):
#         if value is None or type(value) is Verse:
#             return value
# 
#         try:
#             return Verse(value)
#         except (RangeError, Exception) as err:
#             raise forms.ValidationError(err.__str__())
# 
#     def formfield(self, **kwargs):
#         defaults = {'form_class': VerseFormField}
#         defaults.update(kwargs)
#         return super(VerseField, self).formfield(**defaults)
# 
# Path: reformedacademy/utils.py
# def str2bool(v):
# def find_using_property(list, object, property):
# 
# Path: rfmedia/models.py
# class Asset(models.Model):
#     type = models.ForeignKey(Type)
#     tag = models.CharField(max_length=255, blank=True, null=True)
#     url = models.CharField(max_length=255, blank=True, null=True)
#     filesize = models.BigIntegerField(blank=True, null=True)
#     duration = models.CharField(max_length=255, blank=True, null=True)
#     mime_type = models.CharField(max_length=255, blank=True, null=True)
#     thumbnail_url = models.CharField(max_length=255, blank=True, null=True)
#     active = models.IntegerField()
#     created = models.DateTimeField()
#     modified = models.DateTimeField(blank=True, null=True)
# 
#     @property
#     def download_url(self):
#         return self.url
# 
#     class Meta:
#         db_table = 'assets'
# 
#     def __unicode__(self):
#         return self.url


from urllib.parse import urlparse
from bible.djangoforms import VerseField
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils import timezone
from django.utils.crypto import random
from reformedacademy import utils
from rfmedia.models import Asset
import scriptures
                                                        course=self)
        # Log the course was started
        CourseLog.start_course(user)
        return course_progress

    def drop(self, user):
        """Drops a course for a user.

        :param user: User

        """
        progress = self.progress_for_user(user)
        if progress:
            progress.delete()

    def __str__(self):
        return self.name

    def __eq__(self, other):
        if isinstance(other, CourseProgress):
            return other.course.id == self.id
        elif isinstance(other, Course):
            return other.id == self.id

    def total_tasks(self):
        """Returns the total number of tasks (int) for
           a given course."""
        total_tasks = 0
        for lesson in self.lesson_set.all():
            for task in lesson.task_set.all():

# Path: bible/djangoforms.py
# class VerseField(models.Field):
#     description = "A scripture reference to a specific verse"
# 
#     def __init__(self, *args, **kwargs):
#         kwargs['max_length'] = 8
#         super(VerseField, self).__init__(*args, **kwargs)
# 
#     def db_type(self, connection):
#         return 'int(%s)' % self.max_length
# 
#     def get_prep_value(self, value):
#         return hash(value)
# 
#     # def from_db_value(self, value, expression, connection, context):
# 
#     def to_python(self, value):
#         if value is None or type(value) is Verse:
#             return value
# 
#         try:
#             return Verse(value)
#         except (RangeError, Exception) as err:
#             raise forms.ValidationError(err.__str__())
# 
#     def formfield(self, **kwargs):
#         defaults = {'form_class': VerseFormField}
#         defaults.update(kwargs)
#         return super(VerseField, self).formfield(**defaults)
# 
# Path: reformedacademy/utils.py
# def str2bool(v):
# def find_using_property(list, object, property):
# 
# Path: rfmedia/models.py
# class Asset(models.Model):
#     type = models.ForeignKey(Type)
#     tag = models.CharField(max_length=255, blank=True, null=True)
#     url = models.CharField(max_length=255, blank=True, null=True)
#     filesize = models.BigIntegerField(blank=True, null=True)
#     duration = models.CharField(max_length=255, blank=True, null=True)
#     mime_type = models.CharField(max_length=255, blank=True, null=True)
#     thumbnail_url = models.CharField(max_length=255, blank=True, null=True)
#     active = models.IntegerField()
#     created = models.DateTimeField()
#     modified = models.DateTimeField(blank=True, null=True)
# 
#     @property
#     def download_url(self):
#         return self.url
# 
#     class Meta:
#         db_table = 'assets'
# 
#     def __unicode__(self):
#         return self.url


# Path: reformedacademy/models.py
from urllib.parse import urlparse
from bible.djangoforms import VerseField
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils import timezone
from django.utils.crypto import random
from reformedacademy import utils
from rfmedia.models import Asset
import scriptures

                                                        course=self)
        # Log the course was started
        CourseLog.start_course(user)
        return course_progress

    def drop(self, user):
        """Drops a course for a user.

        :param user: User

        """
        progress = self.progress_for_user(user)
        if progress:
            progress.delete()

    def __str__(self):
        return self.name

    def __eq__(self, other):
        if isinstance(other, CourseProgress):
            return other.course.id == self.id
        elif isinstance(other, Course):
            return other.id == self.id

    def total_tasks(self):
        """Returns the total number of tasks (int) for
           a given course."""
        total_tasks = 0
        for lesson in self.lesson_set.all():
            for task in lesson.task_set.all():

                total_tasks += 1