<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_user_settings(self, medium='email'):
 """ Ensure user is ok with receiving this notification through the specified medium. Available mediums are 'web' and 'email', while 'mobile' notifications will hopefully be implemented in the future. """

        # custom notifications are always sent
        if self.type == 'custom':
            return True

        try:
            user_settings = getattr(self.to_user, '%s_notification_settings' % medium)
        except ObjectDoesNotExist:
            # user has no settings specified
            # TODO: it would be better to create the settings with default values
            return False

        user_setting_type = getattr(user_settings.__class__, self.type).user_setting_type

        if user_setting_type == 'boolean':
            return getattr(user_settings, self.type, True)
        elif user_setting_type == 'distance':
            value = getattr(user_settings, self.type, 0)
            # enabled for all related objects
            if value is 0:
                return True
            # disabled for all related objects
            elif value < 0:
                return False
            # enabled for related objects comprised in specified distance range in km
            else:
                Model = self.related_object.__class__
                geo_field = getattr(user_settings.__class__, self.type).geo_field
                geo_value = getattr(self.related_object, geo_field)
                km = value * 1000
                queryset = Model.objects.filter(**{
                    "user_id": self.to_user_id,
                    geo_field + "__distance_lte": (geo_value, km)
                })
                # if user has related object in a distance range less than or equal to
                # his prefered range (specified in number of km), return True and send the notification
                return queryset.count() >= 1