from __future__ import unicode_literals

from django.utils.functional import cached_property

from wagtail.core.blocks import ChooserBlock


class AbstractMediaChooserBlock(ChooserBlock):
    @cached_property
    def target_model(self):
        from wagtailmedia.models import get_media_model

        return get_media_model()

    @cached_property
    def widget(self):
        from wagtailmedia.widgets import AdminMediaChooser

        return AdminMediaChooser()

    def get_form_state(self, value):
        """support telepath for wagtail > 2.12"""
        value_data = self.widget.get_value_data(value)
        return value_data

    def render_basic(self, value, context=None):
        raise NotImplementedError(
            "You need to implement %s.render_basic" % self.__class__.__name__
        )

from __future__ import unicode_literals

from django.utils.functional import cached_property

from wagtail.core.blocks import ChooserBlock


class AbstractMediaChooserBlock(ChooserBlock):
    @cached_property
    def target_model(self):
        from wagtailmedia.models import get_media_model

        return get_media_model()

    @cached_property
    def widget(self):
        from wagtailmedia.widgets import AdminMediaChooser

        return AdminMediaChooser()

    def get_form_state(self, value):
        return self.widget.get_value_data(value)

    def render_basic(self, value, context=None):
        raise NotImplementedError(
            "You need to implement %s.render_basic" % self.__class__.__name__
        )

remove redundant lines