annotate gpp/core/widgets.py @ 114:535d02d1c017

Forums: Implemented unread status for topics and posts.
author Brian Neal <bgneal@gmail.com>
date Sun, 11 Oct 2009 20:27:07 +0000
parents 9bfe07c26c78
children ab7830b067b3
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):
gremmie@1 19 url = reverse('messages-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