# Path: likert_field/templatetags/likert_star_tools.py
# def render_stars(num, max_stars, star_set):
#     """
#     Star renderer returns a HTML string of stars
# 
#     If num is None or a blank string, it returns the unanswered tag
# 
#     Otherwise, the returned string will contain num solid stars
#     followed by max_stars - num empty stars
# 
#     If num > max_stars, render max_stars solid stars
# 
#     star_set is a dictionary of strings with keys: star, unlit, noanswer
#     """
#     if num is None or (isinstance(num, string_types) and len(num) == 0):
#         return star_set['noanswer']
# 
#     difference = int(max_stars) - int(num)
#     if difference < 0:
#         num = max_stars
#         difference = 0
# 
#     return ''.join(
#         star_set['star'] * int(num) + star_set['unlit'] * difference)


from django import template
from django.utils.safestring import mark_safe
from .likert_star_tools import render_stars
#
# Bootstrap glyphicon stars ver 2
star_set_2 = {
    'star': "<i class='icon-star likert-star'></i>",
    'unlit': "<i class='icon-star-empty likert-star'></i>",
    'noanswer': "<i class='icon-ban-circle likert-star'></i>"
}

# Bootstrap glyphicon stars ver 3
star_set_3 = {
    'star': "<i class='glyphicon glyphicon-star likert-star'></i>",
    'unlit': "<i class='glyphicon glyphicon-star-empty likert-star'></i>",
    'noanswer': "<i class='glyphicon glyphicon-ban-circle likert-star'></i>"
}

# Bootstrap glyphicon stars ver 3 for bootstrap-star-rating
star_set_3_bsr = {
    'star': "<i class='glyphicon glyphicon-star likert-star'></i>",
    'unlit': "<i class='glyphicon glyphicon-star-empty likert-star'></i>",
    'noanswer': "<i class='glyphicon glyphicon-minus-sign likert-star'></i>"
}


def bs_stars2(num, max_stars=5):
    """
    Stars for Bootstrap 2

    If num is not None, the returned string will contain num solid stars
    followed by max_stars - num empty stars
    """

# Path: likert_field/templatetags/likert_star_tools.py
# def render_stars(num, max_stars, star_set):
#     """
#     Star renderer returns a HTML string of stars
# 
#     If num is None or a blank string, it returns the unanswered tag
# 
#     Otherwise, the returned string will contain num solid stars
#     followed by max_stars - num empty stars
# 
#     If num > max_stars, render max_stars solid stars
# 
#     star_set is a dictionary of strings with keys: star, unlit, noanswer
#     """
#     if num is None or (isinstance(num, string_types) and len(num) == 0):
#         return star_set['noanswer']
# 
#     difference = int(max_stars) - int(num)
#     if difference < 0:
#         num = max_stars
#         difference = 0
# 
#     return ''.join(
#         star_set['star'] * int(num) + star_set['unlit'] * difference)


# Path: likert_field/templatetags/likert_bs_stars.py
from django import template
from django.utils.safestring import mark_safe
from .likert_star_tools import render_stars

#
# Bootstrap glyphicon stars ver 2
star_set_2 = {
    'star': "<i class='icon-star likert-star'></i>",
    'unlit': "<i class='icon-star-empty likert-star'></i>",
    'noanswer': "<i class='icon-ban-circle likert-star'></i>"
}

# Bootstrap glyphicon stars ver 3
star_set_3 = {
    'star': "<i class='glyphicon glyphicon-star likert-star'></i>",
    'unlit': "<i class='glyphicon glyphicon-star-empty likert-star'></i>",
    'noanswer': "<i class='glyphicon glyphicon-ban-circle likert-star'></i>"
}

# Bootstrap glyphicon stars ver 3 for bootstrap-star-rating
star_set_3_bsr = {
    'star': "<i class='glyphicon glyphicon-star likert-star'></i>",
    'unlit': "<i class='glyphicon glyphicon-star-empty likert-star'></i>",
    'noanswer': "<i class='glyphicon glyphicon-minus-sign likert-star'></i>"
}


def bs_stars2(num, max_stars=5):
    """
    Stars for Bootstrap 2

    If num is not None, the returned string will contain num solid stars
    followed by max_stars - num empty stars
    """

    return mark_safe(render_stars(num, max_stars, star_set_2))