Source code for admin_timeline.forms

__title__ = 'admin_timeline.forms'
__version__ = '0.9'
__build__ = 0x000009
__author__ = 'Artur Barseghyan <>'
__all__ = ('FilterForm',)

from django import forms
from django.contrib.admin.models import LogEntry

# Getting a plain list of all users who have done anything.
data = LogEntry.objects.all().select_related('user', 'content_type').only('content_type', 'user')[:]

users = lambda data: list(set([(d.user_id, d.user.get_full_name() if d.user.get_full_name() else d.user.username) \
                               for d in data]))
content_types = lambda data: list(set([(d.content_type_id, for d in data]))

[docs]class FilterForm(forms.Form): """ Filter form to be used in the timeline. ``users``: Users list to be filtered on. ``content_types``: Content types to be filtered on. """ def __init__(self, *args, **kwargs): super(FilterForm, self).__init__(*args, **kwargs) self.fields['users'] = forms.MultipleChoiceField(choices=users(data), widget=forms.CheckboxSelectMultiple, \ required=False) self.fields['content_types'] = forms.MultipleChoiceField(choices=content_types(data), \ widget=forms.CheckboxSelectMultiple, required=False)
Read the Docs v: 0.9
On Read the Docs
Project Home

Free document hosting provided by Read the Docs.