entity_event/models.py
def entity_events(self, entity, **event_filters):
        """Return subscribed events for a given entity.

        This method of getting events is useful when you want to see
        only the events relevant to a single entity. The events
        returned are events that the given entity is subscribed to,
        either directly as an individual entity, or because they are
        part of a group subscription. As an example, the
        `entity_events` method can be used to implement a newsfeed for
        a individual entity:

        .. code-block:: python

            TEMPLATE = '''
                <html><body>
                <h1> {entity}'s Events </h1>
                <ul>
                {% for event in events %}
                    <li> {{ event.context.event_text }} </li>
                {% endfor %}
                </ul>
                </body></html>
            '''

            def newsfeed(request):
                newsfeed_medium = Medium.objects.get(name='newsfeed')
                entity = Entity.get_for_obj(request.user)
                context = {}
                context['entity'] = entity
                context['events'] = site_feed_medium.entity_events(entity, seen=False, mark_seen=True)
                return HttpResponse(TEMPLATE.render(context))


        The only required argument for this method is the entity to
        get events for. Filtering based on the properties of the
        events themselves is supported, through the rest of the
        following arguments, which are optional.

        :type_entity: Entity
        :param entity: The entity to get events for.

        :type start_time: datetime.datetime (optional)
        :param start_time: Only return events that occurred after the
            given time. If no time is given for this argument, no
            filtering is done.

        :type end_time: datetime.datetime (optional)
        :param end_time: Only return events that occurred before the
            given time. If no time is given for this argument, no
            filtering is done

        :type seen: Boolean (optional)
        :param seen: This flag controls whether events that have
            marked as seen are included. By default, both events that
            have and have not been marked as seen are included. If
            ``True`` is given for this parameter, only events that
            have been marked as seen will be included. If ``False`` is
            given, only events that have not been marked as seen will
            be included.

        :type include_expired: Boolean (optional)
        :param include_expired: By default, events that have a
            expiration time, which has passed, are not included in the
            results. Passing in ``True`` to this argument causes
            expired events to be returned as well.

        :type actor: Entity (optional)
        :param actor: Only include events with the given entity as an
            actor.

        :type mark_seen: Boolean (optional)
        :param mark_seen: Create a side effect in the database that
            marks all the returned events as having been seen by this
            medium.

        :rtype: EventQuerySet
        :returns: A queryset of events.
        """
        events = self.get_filtered_events(**event_filters)

        subscriptions = Subscription.objects.filter(medium=self)
        subscriptions = self.subset_subscriptions(subscriptions, entity)

        subscription_q_objects = [
            Q(
                eventactor__entity__in=self.followed_by(entity),
                source=sub.source
            )
            for sub in subscriptions if sub.only_following
        ]
        subscription_q_objects.append(
            Q(source__in=[sub.source for sub in subscriptions if not sub.only_following])
        )

        return [
            event for event in events.filter(reduce(or_, subscription_q_objects))
            if self.filter_source_targets_by_unsubscription(event.source_id, [entity])
        ]
Return subscribed events for a given entity.

        This method of getting events is useful when you want to see
        only the events relevant to a single entity. The events
        returned are events that the given entity is subscribed to,
        either directly as an individual entity, or because they are
        part of a group subscription. As an example, the
        `entity_events` method can be used to implement a newsfeed for
        a individual entity:

        .. code-block:: python

            TEMPLATE = '''
                <html><body>
                <h1> {entity}'s Events </h1>
                <ul>
                {% for event in events %}
                    <li> {{ event.context.event_text }} </li>
                {% endfor %}
                </ul>
                </body></html>
            '''

            def newsfeed(request):
                newsfeed_medium = Medium.objects.get(name='newsfeed')
                entity = Entity.get_for_obj(request.user)
                context = {}
                context['entity'] = entity
                context['events'] = site_feed_medium.entity_events(entity, seen=False, mark_seen=True)
                return HttpResponse(TEMPLATE.render(context))


        The only required argument for this method is the entity to
        get events for. Filtering based on the properties of the
        events themselves is supported, through the rest of the
        following arguments, which are optional.

        :type_entity: Entity
        :param entity: The entity to get events for.

        :type start_time: datetime.datetime (optional)
        :param start_time: Only return events that occurred after the
            given time. If no time is given for this argument, no
            filtering is done.

        :type end_time: datetime.datetime (optional)
        :param end_time: Only return events that occurred before the
            given time. If no time is given for this argument, no
            filtering is done

        :type seen: Boolean (optional)
        :param seen: This flag controls whether events that have
            marked as seen are included. By default, both events that
            have and have not been marked as seen are included. If
            ``True`` is given for this parameter, only events that
            have been marked as seen will be included. If ``False`` is
            given, only events that have not been marked as seen will
            be included.

        :type include_expired: Boolean (optional)
        :param include_expired: By default, events that have a
            expiration time, which has passed, are not included in the
            results. Passing in ``True`` to this argument causes
            expired events to be returned as well.

        :type actor: Entity (optional)
        :param actor: Only include events with the given entity as an
            actor.

        :type mark_seen: Boolean (optional)
        :param mark_seen: Create a side effect in the database that
            marks all the returned events as having been seen by this
            medium.

        :rtype: EventQuerySet
        :returns: A queryset of events.
        
Return subscribed events for a given entity.
This method of getting events is useful when you want to see
only the events relevant to a single entity. The events
returned are events that the given entity is subscribed to,
either directly as an individual entity, or because they are
part of a group subscription. As an example, the
`entity_events` method can be used to implement a newsfeed for
a individual entity.

code-block:: python





The only required argument for this method is the entity to
get events for. Filtering based on the properties of the
events themselves is supported, through the rest of the
following arguments, which are optional.
Return subscribed events for a given entity . This method of getting events is useful when you want to see only the events relevant to a single entity . The events returned are events that the given entity is subscribed to either directly as an individual entity or because they are part of a group subscription . As an example the ` entity_events ` method can be used to implement a newsfeed for a individual entity . code - block :: python The only required argument for this method is the entity to get events for . Filtering based on the properties of the events themselves is supported through the rest of the following arguments which are optional .
def entity_events(self, entity, **event_filters):
        events = self.get_filtered_events(**event_filters)
        subscriptions = Subscription.objects.filter(medium=self)
        subscriptions = self.subset_subscriptions(subscriptions, entity)
        subscription_q_objects = [
            Q(
                eventactor__entity__in=self.followed_by(entity),
                source=sub.source
            )
            for sub in subscriptions if sub.only_following
        ]
        subscription_q_objects.append(
            Q(source__in=[sub.source for sub in subscriptions if not sub.only_following])
        )
        return [
            event for event in events.filter(reduce(or_, subscription_q_objects))
            if self.filter_source_targets_by_unsubscription(event.source_id, [entity])
        ]
def entity_events ( self , entity , ** event_filters ) : events = self . get_filtered_events ( ** event_filters ) subscriptions = Subscription . objects . filter ( medium = self ) subscriptions = self . subset_subscriptions ( subscriptions , entity ) subscription_q_objects = [ Q ( eventactor__entity__in = self . followed_by ( entity ) , source = sub . source ) for sub in subscriptions if sub . only_following ] subscription_q_objects . append ( Q ( source__in = [ sub . source for sub in subscriptions if not sub . only_following ] ) ) return [ event for event in events . filter ( reduce ( or_ , subscription_q_objects ) ) if self . filter_source_targets_by_unsubscription ( event . source_id , [ entity ] ) ]
Return subscribed events for a given entity.
Return subscribed events for a given entity .
"""Return subscribed events for a given entity.

        This method of getting events is useful when you want to see
        only the events relevant to a single entity. The events
        returned are events that the given entity is subscribed to,
        either directly as an individual entity, or because they are
        part of a group subscription. As an example, the
        `entity_events` method can be used to implement a newsfeed for
        a individual entity:

        .. code-block:: python

            TEMPLATE = '''
                <html><body>
                <h1> {entity}'s Events </h1>
                <ul>
                {% for event in events %}
                    <li> {{ event.context.event_text }} </li>
                {% endfor %}
                </ul>
                </body></html>
            '''

            def newsfeed(request):
                newsfeed_medium = Medium.objects.get(name='newsfeed')
                entity = Entity.get_for_obj(request.user)
                context = {}
                context['entity'] = entity
                context['events'] = site_feed_medium.entity_events(entity, seen=False, mark_seen=True)
                return HttpResponse(TEMPLATE.render(context))


        The only required argument for this method is the entity to
        get events for. Filtering based on the properties of the
        events themselves is supported, through the rest of the
        following arguments, which are optional.

        :type_entity: Entity
        :param entity: The entity to get events for.

        :type start_time: datetime.datetime (optional)
        :param start_time: Only return events that occurred after the
            given time. If no time is given for this argument, no
            filtering is done.

        :type end_time: datetime.datetime (optional)
        :param end_time: Only return events that occurred before the
            given time. If no time is given for this argument, no
            filtering is done

        :type seen: Boolean (optional)
        :param seen: This flag controls whether events that have
            marked as seen are included. By default, both events that
            have and have not been marked as seen are included. If
            ``True`` is given for this parameter, only events that
            have been marked as seen will be included. If ``False`` is
            given, only events that have not been marked as seen will
            be included.

        :type include_expired: Boolean (optional)
        :param include_expired: By default, events that have a
            expiration time, which has passed, are not included in the
            results. Passing in ``True`` to this argument causes
            expired events to be returned as well.

        :type actor: Entity (optional)
        :param actor: Only include events with the given entity as an
            actor.

        :type mark_seen: Boolean (optional)
        :param mark_seen: Create a side effect in the database that
            marks all the returned events as having been seen by this
            medium.

        :rtype: EventQuerySet
        :returns: A queryset of events.
        """
A queryset of events.
A queryset of events .
EventQuerySet
self
entity
The entity to get events for.
The entity to get events for .
start_time
Only return events that occurred after the
given time. If no time is given for this argument, no
filtering is done.
Only return events that occurred after the given time . If no time is given for this argument no filtering is done .
end_time
Only return events that occurred before the
given time. If no time is given for this argument, no
filtering is done
Only return events that occurred before the given time . If no time is given for this argument no filtering is done
seen
This flag controls whether events that have
marked as seen are included. By default, both events that
have and have not been marked as seen are included. If
``True`` is given for this parameter, only events that
have been marked as seen will be included. If ``False`` is
given, only events that have not been marked as seen will
be included.
This flag controls whether events that have marked as seen are included . By default both events that have and have not been marked as seen are included . If ` ` True ` ` is given for this parameter only events that have been marked as seen will be included . If ` ` False ` ` is given only events that have not been marked as seen will be included .
include_expired
By default, events that have a
expiration time, which has passed, are not included in the
results. Passing in ``True`` to this argument causes
expired events to be returned as well.
By default events that have a expiration time which has passed are not included in the results . Passing in ` ` True ` ` to this argument causes expired events to be returned as well .
actor
Only include events with the given entity as an
actor.
Only include events with the given entity as an actor .
mark_seen
Create a side effect in the database that
marks all the returned events as having been seen by this
medium.
Create a side effect in the database that marks all the returned events as having been seen by this medium .
type_entity
None