# -*- coding: utf-8 -*-
from cms.toolbar_pool import toolbar_pool
from cms.extensions.toolbar import ExtensionToolbar
from django.utils.translation import ugettext_lazy as _

from project.models import ImageExtension


@toolbar_pool.register
class ImageExtensionToolbar(ExtensionToolbar):
    model = ImageExtension

    def populate(self):
        current_page_menu = self._setup_extension_toolbar()

        if current_page_menu:
            page_extension, url = self.get_page_extension_admin()
            if url:
                current_page_menu.add_modal_item('Seiten-Bild', url=url, disabled=not self.toolbar.edit_mode,
                                                 position=0)
