from ploneintranet.workspace.interfaces import IObjectModifiedAfterCreationEvent
from ploneintranet.workspace.interfaces import IObjectTrashedEvent
from ploneintranet.workspace.interfaces import IParticipationPolicyChangedEvent
from ploneintranet.workspace.interfaces import IWorkspaceCreatedFromTemplateEvent
from ploneintranet.workspace.interfaces import IWorkspaceRosterChangedEvent
from zope.interface import implementer
from zope.interface.interfaces import ObjectEvent
from zope.lifecycleevent import ObjectModifiedEvent


@implementer(IParticipationPolicyChangedEvent)
class ParticipationPolicyChangedEvent(ObjectEvent):
    """Event class, which is fired once the participation policy
    of the workspace has changed
    """

    def __init__(self, ob, old_policy, new_policy):
        super().__init__(ob)
        self.old_policy = old_policy
        self.new_policy = new_policy


@implementer(IWorkspaceRosterChangedEvent)
class WorkspaceRosterChangedEvent(ObjectEvent):
    """
    Event, which is fired once the roster of a workspace had changed
    """

    def __init__(self, ob):
        super().__init__(ob)


@implementer(IWorkspaceCreatedFromTemplateEvent)
class WorkspaceCreatedFromTemplateEvent(ObjectEvent):
    """ """


@implementer(IObjectModifiedAfterCreationEvent)
class ObjectModifiedAfterCreationEvent(ObjectModifiedEvent):
    """Like ObjectModifiedEvent, but only fired in the special case where we
    set the fields of an object after first creating it empty. Can be used
    like an ObjectCreatedEvent in plain Plone.
    """


@implementer(IObjectTrashedEvent)
class ObjectTrashedEvent(ObjectEvent):
    """Event that is fired when an object is trashed"""
