def likebutton_enabled(context, settings):
    """
    Returns a boolean indicating whether the Like button is enabled for this
    content object.
    """

    if ILikeButtonDisabled.providedBy(context):
        # If Like buttons have been disabled for this content object, we
        # shouldn't check anything else.
        return False

    # Check if this type is in the enabled types or if it has the enabled
    # marker interface.
    if context.portal_type in settings.like_button_types or ILikeButtonEnabled.providedBy(context):
        return True
    return False
def likebutton_enabled(context, settings):
    """
    Returns a boolean indicating whether the Like button is enabled for this
    content object.
    """

    if ILikeButtonDisabled.providedBy(context):
        # If Like buttons have been disabled for this content object, we
        # shouldn't check anything else.
        return False

    # Check if this type is in the enabled types or if it has the enabled
    # marker interface.
    if context.portal_type in settings.like_button_types or \
        ILikeButtonEnabled.providedBy(context):
        return True
    return False
    def __call__(self):

        # Decide whether we are enabling or disabling based on the request.
        enable = self.request.get("enable", False)
        settings = self._get_settings()

        if enable:
            if ILikeButtonDisabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonDisabled)
            if not self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonEnabled)
            IStatusMessage(self.request).addStatusMessage(_(u"Like button enabled."), type="info")
        else:
            if ILikeButtonEnabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonEnabled)
            if self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonDisabled)
            IStatusMessage(self.request).addStatusMessage(_(u"Like button disabled."), type="info")

        return self.request.RESPONSE.redirect(self.context.absolute_url())
    def __call__(self):

        # Decide whether we are enabling or disabling based on the request.
        enable = self.request.get('enable', False)
        settings = self._get_settings()

        if enable:
            if ILikeButtonDisabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonDisabled)
            if not self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonEnabled)
            IStatusMessage(self.request).addStatusMessage(
                _(u'Like button enabled.'), type='info')
        else:
            if ILikeButtonEnabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonEnabled)
            if self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonDisabled)
            IStatusMessage(self.request).addStatusMessage(
                _(u'Like button disabled.'), type='info')

        return self.request.RESPONSE.redirect(self.context.absolute_url())