entity_event/models.py
def events(self, **event_filters):
        """Return subscribed events, with basic filters.

        This method of getting events is useful when you want to
        display events for your medium, independent of what entities
        were involved in those events. For example, this method can be
        used to display a list of site-wide events that happened in the
        past 24 hours:

        .. code-block:: python

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

            def site_feed(request):
                site_feed_medium = Medium.objects.get(name='site_feed')
                start_time = datetime.utcnow() - timedelta(days=1)
                context = {}
                context['events'] = site_feed_medium.events(start_time=start_time)
                return HttpResponse(TEMPLATE.render(context))

        While the `events` method does not filter events based on what
        entities are involved, filtering based on the properties of the events
        themselves is supported, through the following arguments, all
        of which are optional.

        :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)

        subscription_q_objects = [
            Q(
                eventactor__entity__in=self.followed_by(sub.subscribed_entities()),
                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]))

        events = events.filter(reduce(or_, subscription_q_objects))
        return events
Return subscribed events, with basic filters.

        This method of getting events is useful when you want to
        display events for your medium, independent of what entities
        were involved in those events. For example, this method can be
        used to display a list of site-wide events that happened in the
        past 24 hours:

        .. code-block:: python

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

            def site_feed(request):
                site_feed_medium = Medium.objects.get(name='site_feed')
                start_time = datetime.utcnow() - timedelta(days=1)
                context = {}
                context['events'] = site_feed_medium.events(start_time=start_time)
                return HttpResponse(TEMPLATE.render(context))

        While the `events` method does not filter events based on what
        entities are involved, filtering based on the properties of the events
        themselves is supported, through the following arguments, all
        of which are optional.

        :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, with basic filters.
This method of getting events is useful when you want to
display events for your medium, independent of what entities
were involved in those events. For example, this method can be
used to display a list of site-wide events that happened in the
past 24 hours.

code-block:: python





While the `events` method does not filter events based on what
entities are involved, filtering based on the properties of the events
themselves is supported, through the following arguments, all
of which are optional.
Return subscribed events with basic filters . This method of getting events is useful when you want to display events for your medium independent of what entities were involved in those events . For example this method can be used to display a list of site - wide events that happened in the past 24 hours . code - block :: python While the ` events ` method does not filter events based on what entities are involved filtering based on the properties of the events themselves is supported through the following arguments all of which are optional .
def events(self, **event_filters):
        events = self.get_filtered_events(**event_filters)
        subscriptions = Subscription.objects.filter(medium=self)
        subscription_q_objects = [
            Q(
                eventactor__entity__in=self.followed_by(sub.subscribed_entities()),
                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]))
        events = events.filter(reduce(or_, subscription_q_objects))
        return events
def events ( self , ** event_filters ) : events = self . get_filtered_events ( ** event_filters ) subscriptions = Subscription . objects . filter ( medium = self ) subscription_q_objects = [ Q ( eventactor__entity__in = self . followed_by ( sub . subscribed_entities ( ) ) , 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 ] ) ) events = events . filter ( reduce ( or_ , subscription_q_objects ) ) return events
Return subscribed events, with basic filters.
Return subscribed events with basic filters .
"""Return subscribed events, with basic filters.

        This method of getting events is useful when you want to
        display events for your medium, independent of what entities
        were involved in those events. For example, this method can be
        used to display a list of site-wide events that happened in the
        past 24 hours:

        .. code-block:: python

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

            def site_feed(request):
                site_feed_medium = Medium.objects.get(name='site_feed')
                start_time = datetime.utcnow() - timedelta(days=1)
                context = {}
                context['events'] = site_feed_medium.events(start_time=start_time)
                return HttpResponse(TEMPLATE.render(context))

        While the `events` method does not filter events based on what
        entities are involved, filtering based on the properties of the events
        themselves is supported, through the following arguments, all
        of which are optional.

        :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
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 .