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

from mtp.apps.assessments.models.competencies import Competency, CompetencyTree, Dimension
from mtp.apps.import_export import resources


class DimensionResource(resources.Resource):
    fields = ('name', 'code', 'default_weight')
    fields_to_get = ('code',)
    fields_to_translate = ('name', 'description')
    fk_fields_to_translate = ('competency',)


class CompetencyResource(resources.Resource):
    fields = ('name', 'code')
    fields_to_get = ('code',)
    fields_to_translate = ('name', 'description')
    fk_fields_to_translate = ('tree',)
    nested_resource = (
        ('dimensions', DimensionResource),
    )


class CompetencyTreeResource(resources.Resource):
    fields = ('job_profile',)
    fields_to_translate = ('name',)
    nested_resource = (
        ('competencies', CompetencyResource),
    )


resources.register(CompetencyTree, CompetencyTreeResource)
resources.register(Competency, CompetencyResource)
resources.register(Dimension, DimensionResource)
