blob: 74c08cc4674905815b89a0a176b49a8897b9988a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
from django.contrib.auth.models import User
from selectable.base import ModelLookup
from selectable.registry import registry
from selectable.decorators import login_required
@login_required
class UserLookup(ModelLookup):
model = User
search_fields = (
'username__icontains',
'first_name__icontains',
'last_name__icontains',
)
filters = {'is_active': True, }
def get_item_value(self, item):
# Display for currently selected item
return u"%s (%s)" % (item.username, item.get_full_name())
def get_item_label(self, item):
# Display for choice listings
return u"%s (%s)" % (item.username, item.get_full_name())
registry.register(UserLookup)
|