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

from mtp.apps.brainstormers.models import (
    Brainstormer, BrainstormerProposition, BrainstormerPropositionGroup, BrainstormerTemplate
)
from mtp.apps.import_export import resources


class BrainstormerPropositionResource(resources.Resource):
    """ Resource for BrainstormerProposition. """

    fields = (
        ('text', 'Proposition text'),
        ('user__username', 'Author')
    )


class BrainstormerGroupResource(resources.Resource):
    """ Resource for BrainstormerPropositionGroup. """

    fields = (
        ('name', 'Group Name'),
        ('color', 'Group color'),
        'coord_x',
        'coord_y',
    )
    fields_to_get = ('name', 'brainstormer')
    header_comments = {
        'name': 'Name of group',
    }
    nested_resource = (('propositions', BrainstormerPropositionResource),)


class BrainstormerResource(resources.Resource):
    """ Resource for Brainstormer. """

    fields = (
        ('name', 'Brainstormer title'),
        ('activity__name', 'Activity')
    )
    nested_resource = (('get_groups', BrainstormerGroupResource),)


class BrainstormerTemplateResource(resources.Resource):
    """ Resource for BrainstormerPropositionGroup. """
    fields = ('name', 'activity__name')
    fields_to_translate = ('name',)

resources.register(Brainstormer, BrainstormerResource)
resources.register(BrainstormerProposition, BrainstormerPropositionResource)
resources.register(BrainstormerPropositionGroup, BrainstormerGroupResource)
resources.register(BrainstormerTemplate, BrainstormerTemplateResource)
