from django import template
from tasks.constants import ApprenticeTaskAnswerStatus
from utils.general import progress_percent

register = template.Library()


@register.simple_tag(name='icon_class_name')
def task_status_icon_class_name(status):
    task_status_icon_class_name_dict = {
        ApprenticeTaskAnswerStatus.BLOCKED: '',
        ApprenticeTaskAnswerStatus.FIRST_UPLOAD: 'first_upload',
        ApprenticeTaskAnswerStatus.BEFORE_MENTOR_RATE: 'before_mentor_rate',
        ApprenticeTaskAnswerStatus.BEFORE_EXERCISES_DONE: 'before_exercises',
        ApprenticeTaskAnswerStatus.SECOND_UPLOAD: 'second_upload',
        ApprenticeTaskAnswerStatus.COMPLETED: 'completed'
    }
    return task_status_icon_class_name_dict.get(status, '')


@register.simple_tag(name='percent')
def percent(value, all):
    return progress_percent(value, all)
