'A function that returns an XBlockUser from the current Django request.user'

def _convert_django_user_to_xblock_user(self, django_user):

    xblock_user = XBlockUser(is_current_user=True)
    if ((django_user is not None) and django_user.is_authenticated()):
        if hasattr(django_user, 'profile'):
            full_name = django_user.profile.name
        else:
            full_name = None
        xblock_user.full_name = full_name
        xblock_user.emails = [django_user.email]
        xblock_user.opt_attrs[ATTR_KEY_IS_AUTHENTICATED] = True
        xblock_user.opt_attrs[ATTR_KEY_USER_ID] = django_user.id
        xblock_user.opt_attrs[ATTR_KEY_USERNAME] = django_user.username
        xblock_user.opt_attrs[ATTR_KEY_USER_IS_STAFF] = django_user.user_is_staff
        user_preferences = get_user_preferences(django_user)
        xblock_user.opt_attrs[ATTR_KEY_USER_PREFERENCES] = {pref: user_preferences.get(pref) for pref in USER_PREFERENCES_WHITE_LIST if (pref in user_preferences)}
    else:
        xblock_user.opt_attrs[ATTR_KEY_IS_AUTHENTICATED] = False
    return xblock_user
