from ...utils import parent_workspace
from plone import api
from plone.memoize.view import memoize
from plone.tiles import Tile
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile


class WorkspaceTabsTile(Tile):

    index = ViewPageTemplateFile("templates/workspace-tabs-tile.pt")

    def has_video_conference(self):
        return bool(
            api.portal.get_registry_record(
                "ploneintranet.workspace.video_conference_server", default=""
            )
        )

    @memoize
    def workspace(self):
        # Attempt to acquire the current workspace
        return parent_workspace(self.context)
