entity_event/models.py
def create_event(self, actors=None, ignore_duplicates=False, **kwargs):
        """Create events with actors.

        This method can be used in place of ``Event.objects.create``
        to create events, and the appropriate actors. It takes all the
        same keywords as ``Event.objects.create`` for the event
        creation, but additionally takes a list of actors, and can be
        told to not attempt to create an event if a duplicate event
        exists.

        :type source: Source
        :param source: A ``Source`` object representing where the
            event came from.

        :type context: dict
        :param context: A dictionary containing relevant
            information about the event, to be serialized into
            JSON. It is possible to load additional context
            dynamically  when events are fetched. See the
            documentation on the ``context_loader`` field in
            ``Source``.

        :type uuid: str
        :param uuid: A unique string for the event. Requiring a
            ``uuid`` allows code that creates events to ensure they do
            not create duplicate events. This id could be, for example
            some hash of the ``context``, or, if the creator is
            unconcerned with creating duplicate events a call to
            python's ``uuid1()`` in the ``uuid`` module.

        :type time_expires: datetime (optional)
        :param time_expires: If given, the default methods for
            querying events will not return this event after this time
            has passed.

        :type actors: (optional) List of entities or list of entity ids.
        :param actors: An ``EventActor`` object will be created for
            each entity in the list. This allows for subscriptions
            which are only following certain entities to behave
            appropriately.

        :type ignore_duplicates: (optional) Boolean
        :param ignore_duplicates: If ``True``, a check will be made to
            ensure that an event with the give ``uuid`` does not exist
            before attempting to create the event. Setting this to
            ``True`` allows the creator of events to gracefully ensure
            no duplicates are created.

        :rtype: Event
        :returns: The created event. Alternatively if a duplicate
            event already exists and ``ignore_duplicates`` is
            ``True``, it will return ``None``.
        """
        if ignore_duplicates and self.filter(uuid=kwargs.get('uuid', '')).exists():
            return None

        event = self.create(**kwargs)

        # Allow user to pass pks for actors
        actors = [
            a.id if isinstance(a, Entity) else a
            for a in actors
        ] if actors else []

        EventActor.objects.bulk_create([EventActor(entity_id=actor, event=event) for actor in actors])
        return event
Create events with actors.

        This method can be used in place of ``Event.objects.create``
        to create events, and the appropriate actors. It takes all the
        same keywords as ``Event.objects.create`` for the event
        creation, but additionally takes a list of actors, and can be
        told to not attempt to create an event if a duplicate event
        exists.

        :type source: Source
        :param source: A ``Source`` object representing where the
            event came from.

        :type context: dict
        :param context: A dictionary containing relevant
            information about the event, to be serialized into
            JSON. It is possible to load additional context
            dynamically  when events are fetched. See the
            documentation on the ``context_loader`` field in
            ``Source``.

        :type uuid: str
        :param uuid: A unique string for the event. Requiring a
            ``uuid`` allows code that creates events to ensure they do
            not create duplicate events. This id could be, for example
            some hash of the ``context``, or, if the creator is
            unconcerned with creating duplicate events a call to
            python's ``uuid1()`` in the ``uuid`` module.

        :type time_expires: datetime (optional)
        :param time_expires: If given, the default methods for
            querying events will not return this event after this time
            has passed.

        :type actors: (optional) List of entities or list of entity ids.
        :param actors: An ``EventActor`` object will be created for
            each entity in the list. This allows for subscriptions
            which are only following certain entities to behave
            appropriately.

        :type ignore_duplicates: (optional) Boolean
        :param ignore_duplicates: If ``True``, a check will be made to
            ensure that an event with the give ``uuid`` does not exist
            before attempting to create the event. Setting this to
            ``True`` allows the creator of events to gracefully ensure
            no duplicates are created.

        :rtype: Event
        :returns: The created event. Alternatively if a duplicate
            event already exists and ``ignore_duplicates`` is
            ``True``, it will return ``None``.
        
Create events with actors.
This method can be used in place of ``Event.objects.create``
to create events, and the appropriate actors. It takes all the
same keywords as ``Event.objects.create`` for the event
creation, but additionally takes a list of actors, and can be
told to not attempt to create an event if a duplicate event
exists.
Create events with actors . This method can be used in place of ` ` Event . objects . create ` ` to create events and the appropriate actors . It takes all the same keywords as ` ` Event . objects . create ` ` for the event creation but additionally takes a list of actors and can be told to not attempt to create an event if a duplicate event exists .
def create_event(self, actors=None, ignore_duplicates=False, **kwargs):
        if ignore_duplicates and self.filter(uuid=kwargs.get('uuid', '')).exists():
            return None
        event = self.create(**kwargs)
        actors = [
            a.id if isinstance(a, Entity) else a
            for a in actors
        ] if actors else []
        EventActor.objects.bulk_create([EventActor(entity_id=actor, event=event) for actor in actors])
        return event
def create_event ( self , actors = None , ignore_duplicates = False , ** kwargs ) : if ignore_duplicates and self . filter ( uuid = kwargs . get ( 'uuid' , '' ) ) . exists ( ) : return None event = self . create ( ** kwargs ) actors = [ a . id if isinstance ( a , Entity ) else a for a in actors ] if actors else [ ] EventActor . objects . bulk_create ( [ EventActor ( entity_id = actor , event = event ) for actor in actors ] ) return event
Create events with actors.
Create events with actors .
"""Create events with actors.

        This method can be used in place of ``Event.objects.create``
        to create events, and the appropriate actors. It takes all the
        same keywords as ``Event.objects.create`` for the event
        creation, but additionally takes a list of actors, and can be
        told to not attempt to create an event if a duplicate event
        exists.

        :type source: Source
        :param source: A ``Source`` object representing where the
            event came from.

        :type context: dict
        :param context: A dictionary containing relevant
            information about the event, to be serialized into
            JSON. It is possible to load additional context
            dynamically  when events are fetched. See the
            documentation on the ``context_loader`` field in
            ``Source``.

        :type uuid: str
        :param uuid: A unique string for the event. Requiring a
            ``uuid`` allows code that creates events to ensure they do
            not create duplicate events. This id could be, for example
            some hash of the ``context``, or, if the creator is
            unconcerned with creating duplicate events a call to
            python's ``uuid1()`` in the ``uuid`` module.

        :type time_expires: datetime (optional)
        :param time_expires: If given, the default methods for
            querying events will not return this event after this time
            has passed.

        :type actors: (optional) List of entities or list of entity ids.
        :param actors: An ``EventActor`` object will be created for
            each entity in the list. This allows for subscriptions
            which are only following certain entities to behave
            appropriately.

        :type ignore_duplicates: (optional) Boolean
        :param ignore_duplicates: If ``True``, a check will be made to
            ensure that an event with the give ``uuid`` does not exist
            before attempting to create the event. Setting this to
            ``True`` allows the creator of events to gracefully ensure
            no duplicates are created.

        :rtype: Event
        :returns: The created event. Alternatively if a duplicate
            event already exists and ``ignore_duplicates`` is
            ``True``, it will return ``None``.
        """ # Allow user to pass pks for actors
The created event. Alternatively if a duplicate
event already exists and ``ignore_duplicates`` is
``True``, it will return ``None``.
The created event . Alternatively if a duplicate event already exists and ` ` ignore_duplicates ` ` is ` ` True ` ` it will return ` ` None ` ` .
Event
self
actors
An ``EventActor`` object will be created for
each entity in the list. This allows for subscriptions
which are only following certain entities to behave
appropriately.
An ` ` EventActor ` ` object will be created for each entity in the list . This allows for subscriptions which are only following certain entities to behave appropriately .
ignore_duplicates
If ``True``, a check will be made to
ensure that an event with the give ``uuid`` does not exist
before attempting to create the event. Setting this to
``True`` allows the creator of events to gracefully ensure
no duplicates are created.
If ` ` True ` ` a check will be made to ensure that an event with the give ` ` uuid ` ` does not exist before attempting to create the event . Setting this to ` ` True ` ` allows the creator of events to gracefully ensure no duplicates are created .
source
A ``Source`` object representing where the
event came from.
A ` ` Source ` ` object representing where the event came from .
context
A dictionary containing relevant
information about the event, to be serialized into
JSON. It is possible to load additional context
dynamically  when events are fetched. See the
documentation on the ``context_loader`` field in
``Source``.
A dictionary containing relevant information about the event to be serialized into JSON . It is possible to load additional context dynamically when events are fetched . See the documentation on the ` ` context_loader ` ` field in ` ` Source ` ` .
uuid
A unique string for the event. Requiring a
``uuid`` allows code that creates events to ensure they do
not create duplicate events. This id could be, for example
some hash of the ``context``, or, if the creator is
unconcerned with creating duplicate events a call to
python's ``uuid1()`` in the ``uuid`` module.
A unique string for the event . Requiring a ` ` uuid ` ` allows code that creates events to ensure they do not create duplicate events . This id could be for example some hash of the ` ` context ` ` or if the creator is unconcerned with creating duplicate events a call to python ' s ` ` uuid1 () ` ` in the ` ` uuid ` ` module .
time_expires
If given, the default methods for
querying events will not return this event after this time
has passed.
If given the default methods for querying events will not return this event after this time has passed .