""" Resource used for import/export evaluations data.
A documentation about Resource is available in import_export.resources module.
"""

from mtp.apps.import_export import resources

from .models import Criterion, Evaluation, Exercise


class EvaluationCriterionResource(resources.Resource):
    fields = (
        ('criterion_type', 'Criterion type'),
        ('description', 'Criterion description'),
    )
    fields_to_translate = ('description',)
    fk_fields_to_translate = ('exercise',)


class EvaluationExerciseResource(resources.Resource):
    fields = (
        ('name', 'Exercise label'),
        ('start_range', 'Exercise start range'),
        ('end_range', 'Exercise end range'),
        ('step', 'Exercise step'),
    )
    fields_to_translate = ('name', 'description')
    nested_resource = (
        ('criteria', EvaluationCriterionResource),
    )


class EvaluationResource(resources.Resource):
    fields = (
        ('name', 'NAME (EVALUATION TYPE PROPERTIES)'),
    )
    fields_to_translate = ('name',)
    fk_fields_to_translate = ('evaluation_type',)
    nested_resource = (
        ('exercises', EvaluationExerciseResource),
    )


resources.register(Evaluation, EvaluationResource)
resources.register(Exercise, EvaluationExerciseResource)
resources.register(Criterion, EvaluationCriterionResource)
