Skip to content

Filters

hypha.apply.activity.filters

NotificationFilter

Bases: FilterSet

timestamp_choices class-attribute instance-attribute

timestamp_choices = [('today', _('Today')), ('yesterday', _('Yesterday')), ('week', _('Past 7 days')), ('month', _('This month')), ('three_months', _('Last 3 months'))]

timestamp_filters class-attribute instance-attribute

timestamp_filters = {'today': lambda qs, name: qs.filter(**{'%s__year' % name: now().year, '%s__month' % name: now().month, '%s__day' % name: now().day}), 'yesterday': lambda qs, name: qs.filter(**{'%s__year' % name: (now() - timedelta(days=1)).year, '%s__month' % name: (now() - timedelta(days=1)).month, '%s__day' % name: (now() - timedelta(days=1)).day}), 'week': lambda qs, name: qs.filter(**{'%s__gte' % name: _truncate(now() - timedelta(days=7)), '%s__lt' % name: _truncate(now() + timedelta(days=1))}), 'month': lambda qs, name: qs.filter(**{'%s__year' % name: now().year, '%s__month' % name: now().month}), 'three_months': lambda qs, name: qs.filter(**{'%s__gte' % name: _truncate(now() - timedelta(days=90)), '%s__lt' % name: _truncate(now() + timedelta(days=1))})}

date class-attribute instance-attribute

date = DateRangeFilter(field_name='timestamp', choices=timestamp_choices, filters=timestamp_filters)

Meta

model class-attribute instance-attribute
model = Activity
fields class-attribute instance-attribute
fields = {}