# Path: cpm_generic/models.py
# class TranslatedField(object):
#     def __init__(self, en_field, be_field, ru_field):
#         self.en_field = en_field
#         self.be_field = be_field
#         self.ru_field = ru_field
# 
#     def __get__(self, instance, owner):
#         fields = {
#             'en': self.en_field,
#             'be': self.be_field,
#             'ru': self.ru_field,
#         }
#         field = fields.get(translation.get_language(), self.en_field)
#         return getattr(instance, field)
# 
# Path: modeladminutils/edit_handlers.py
# class AdminModelChooserPanel(object):
#     def __init__(self, field_name):
#         self.field_name = field_name
# 
#     def bind_to_model(self, model):
#         return type(
#             str('_AdminModelChooserPanel'),
#             (BaseAdminModelChooserPanel,),
#             {
#                 'model': model,
#                 'field_name': self.field_name,
#             }
#         )


from django.db import models
from django.utils.translation import ugettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Orderable, Page
from wagtail.wagtailadmin.edit_handlers import (FieldPanel,
                                                InlinePanel,
                                                PageChooserPanel)
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from cpm_generic.models import TranslatedField
from modeladminutils.edit_handlers import AdminModelChooserPanel
        DEFAULT = BOTTOM
        CHOICES = [
            (TOP, _(u'Top')),
            (BOTTOM, _(u'Bottom')),
        ]

    page = ParentalKey('ResultsPage', related_name='related_facts')

    number = models.CharField(max_length=10, default='')

    caption_en = models.CharField(max_length=100, default='')
    position_en = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption_be = models.CharField(max_length=100, default='')
    position_be = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption_ru = models.CharField(max_length=100, default='')
    position_ru = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption = TranslatedField('caption_en', 'caption_be', 'caption_ru')
    position = TranslatedField('position_en', 'position_be', 'position_ru')


class PartnerPage(Page):
    name_en = models.CharField(max_length=250)
    name_be = models.CharField(max_length=250)
    name_ru = models.CharField(max_length=250)

# Path: cpm_generic/models.py
# class TranslatedField(object):
#     def __init__(self, en_field, be_field, ru_field):
#         self.en_field = en_field
#         self.be_field = be_field
#         self.ru_field = ru_field
# 
#     def __get__(self, instance, owner):
#         fields = {
#             'en': self.en_field,
#             'be': self.be_field,
#             'ru': self.ru_field,
#         }
#         field = fields.get(translation.get_language(), self.en_field)
#         return getattr(instance, field)
# 
# Path: modeladminutils/edit_handlers.py
# class AdminModelChooserPanel(object):
#     def __init__(self, field_name):
#         self.field_name = field_name
# 
#     def bind_to_model(self, model):
#         return type(
#             str('_AdminModelChooserPanel'),
#             (BaseAdminModelChooserPanel,),
#             {
#                 'model': model,
#                 'field_name': self.field_name,
#             }
#         )


# Path: results/models.py
from django.db import models
from django.utils.translation import ugettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.wagtailcore.models import Orderable, Page
from wagtail.wagtailadmin.edit_handlers import (FieldPanel,
                                                InlinePanel,
                                                PageChooserPanel)
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from cpm_generic.models import TranslatedField
from modeladminutils.edit_handlers import AdminModelChooserPanel

        DEFAULT = BOTTOM
        CHOICES = [
            (TOP, _(u'Top')),
            (BOTTOM, _(u'Bottom')),
        ]

    page = ParentalKey('ResultsPage', related_name='related_facts')

    number = models.CharField(max_length=10, default='')

    caption_en = models.CharField(max_length=100, default='')
    position_en = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption_be = models.CharField(max_length=100, default='')
    position_be = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption_ru = models.CharField(max_length=100, default='')
    position_ru = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption = TranslatedField('caption_en', 'caption_be', 'caption_ru')
    position = TranslatedField('position_en', 'position_be', 'position_ru')


class PartnerPage(Page):
    name_en = models.CharField(max_length=250)
    name_be = models.CharField(max_length=250)
    name_ru = models.CharField(max_length=250)

    name = TranslatedField('name_en', 'name_be', 'name_ru')