'Looks up a badge class by its slug, issuing component, and course_id and returns it should it exist.
If it does not exist, and create is True, creates it according to the arguments. Otherwise, returns None.
The expectation is that an XBlock or platform developer should not need to concern themselves with whether
or not a badge class has already been created, but should just feed all requirements to this function
and it will \'do the right thing\'. It should be the exception, rather than the common case, that a badge class
would need to be looked up without also being created were it missing.'

@classmethod
def get_badge_class(cls, slug, issuing_component, display_name=None, description=None, criteria=None, image_file_handle=None, mode='', course_id=None, create=True):

    slug = slug.lower()
    issuing_component = issuing_component.lower()
    if (course_id and (not modulestore().get_course(course_id).issue_badges)):
        raise CourseBadgesDisabledError('This    course    does    not    have    badges    enabled.')
    if (not course_id):
        course_id = CourseKeyField.Empty
    try:
        return cls.objects.get(slug=slug, issuing_component=issuing_component, course_id=course_id)
    except cls.DoesNotExist:
        if (not create):
            return None
    badge_class = cls(slug=slug, issuing_component=issuing_component, display_name=display_name, course_id=course_id, mode=mode, description=description, criteria=criteria)
    badge_class.image.save(image_file_handle.name, image_file_handle)
    badge_class.full_clean()
    badge_class.save()
    return badge_class
