    1: from zope import component
    1: from zope import interface
    1: from zope import schema
    1: from slc.publications import interfaces
       
    2: class IContextualPublicationSupport(interfaces.IBasicPublicationSupport):
    1:     can_activate_publication = schema.Bool(title=u'Can Activate Publication',
    1:                                      readonly=True)
    1:     can_deactivate_publication = schema.Bool(title=u'Can Deactivate Publication',
    1:                                        readonly=True)
       
    2: class Support(object):
           """A view that returns certain information regarding p4acal status.
           """
       
    1:     interface.implements(IContextualPublicationSupport)
           
    1:     def __init__(self, context, request):
>>>>>>         self.context = context
>>>>>>         self.request = request
               
    1:     @property
           def support_enabled(self):
               """Check to make sure an IPublicationSupport utility is available and
               if so, query it to determine if support is enabled.
               """
               
>>>>>>         support = component.queryUtility(interfaces.IPublicationSupport)
>>>>>>         if support is None:
>>>>>>             return False
       
>>>>>>         return support.support_enabled
       
    1:     @property
           def _basic_can(self):
>>>>>>         if not self.support_enabled:
>>>>>>             return False
       
>>>>>>         if not interfaces.IAnyPublicationCapable.providedBy(self.context):
>>>>>>             return False
       
>>>>>>         return True
       
    1:     @property
           def can_activate_video(self):
>>>>>>         if not self._basic_can:
>>>>>>             return False
               
>>>>>>         mediaconfig = component.getMultiAdapter((self.context, self.request),
>>>>>>                                                 name='publication-config.html')
>>>>>>         return not mediaconfig.media_activated
       
    1:     @property
           def can_deactivate_video(self):
>>>>>>         if not self._basic_can:
>>>>>>             return False
               
>>>>>>         mediaconfig = component.getMultiAdapter((self.context, self.request),
>>>>>>                                                 name='publication-config.html')
>>>>>>         return mediaconfig.media_activated
