annotate gpp/core/widgets.py @ 164:f7a6b8fe4556
Implement #46, add a forums stat feature like phpBB.
author |
Brian Neal <bgneal@gmail.com> |
date |
Mon, 28 Dec 2009 16:52:42 +0000 |
parents |
ab7830b067b3 |
children |
be3fff614b93 |
rev |
line source |
gremmie@1
|
1 """
|
gremmie@1
|
2 Various useful widgets for the GPP application.
|
gremmie@1
|
3 """
|
gremmie@1
|
4
|
gremmie@1
|
5 from django import forms
|
gremmie@1
|
6 from django.utils.safestring import mark_safe
|
gremmie@1
|
7 from django.core.urlresolvers import reverse
|
bgneal@6
|
8 from django.conf import settings
|
gremmie@1
|
9
|
gremmie@1
|
10
|
gremmie@1
|
11 class AutoCompleteUserInput(forms.TextInput):
|
gremmie@1
|
12 class Media:
|
gremmie@1
|
13 css = {
|
bgneal@6
|
14 'all': settings.GPP_THIRD_PARTY_CSS['jquery-autocomplete'],
|
gremmie@1
|
15 }
|
bgneal@12
|
16 js = settings.GPP_THIRD_PARTY_JS['jquery-autocomplete']
|
gremmie@1
|
17
|
gremmie@1
|
18 def render(self, name, value, attrs=None):
|
bgneal@149
|
19 url = reverse('core-ajax_users')
|
gremmie@1
|
20 output = super(AutoCompleteUserInput, self).render(name, value, attrs)
|
gremmie@1
|
21 return output + mark_safe(u'''\
|
gremmie@1
|
22 <script type="text/javascript">
|
gremmie@1
|
23 jQuery("#id_%s").autocomplete("%s", {
|
gremmie@1
|
24 width: 150,
|
gremmie@1
|
25 max: 10,
|
gremmie@1
|
26 highlight: false,
|
gremmie@1
|
27 multiple: false,
|
gremmie@1
|
28 scroll: true,
|
gremmie@1
|
29 scrollHeight: 300,
|
gremmie@1
|
30 matchContains: true,
|
bgneal@56
|
31 autoFill: true
|
gremmie@1
|
32 });
|
gremmie@1
|
33 </script>''' % (name, url))
|
gremmie@1
|
34
|