Test coverage report: calendarium.widgets

# calendarium.widgets: 13 total statements, 60.0% covered

Generated: Sun 2013-03-24 21:11 CET

Source file: /home/tobi/Projects/calendarium/src/calendarium/widgets.py

Stats: 6 executed, 4 missed, 3 excluded, 28 ignored

1. `"""Widgets for the ``calendarium`` app."""`
2. `from django import forms`
3. `from django.conf import settings`
4. `from django.utils.safestring import mark_safe`
5. ``
6. ``
7. `class ColorPickerWidget(forms.TextInput):`
8. `class Media:`
9. `css = {`
10. `'all': (`
11. `settings.STATIC_URL + 'calendarium/css/colorpicker.css',`
12. `)`
13. `}`
14. `js = (`
15. `'//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js',`
16. `settings.STATIC_URL + 'calendarium/js/colorpicker.js',`
17. `settings.STATIC_URL + 'calendarium/js/eye.js',`
18. `settings.STATIC_URL + 'calendarium/js/layout.js',`
19. `settings.STATIC_URL + 'calendarium/js/utils.js',`
20. `)`
21. ``
22. `def __init__(self, language=None, attrs=None):`
23. `self.language = language or settings.LANGUAGE_CODE[:2]`
24. `super(ColorPickerWidget, self).__init__(attrs=attrs)`
25. ``
26. `def render(self, name, value, attrs=None):`
27. `rendered = super(ColorPickerWidget, self).render(name, value, attrs)`
28. `return rendered + mark_safe(`
29. `u'''<script type="text/javascript">`
30. `$('#id_%s').ColorPicker({`
31. `onSubmit: function(hsb, hex, rgb, el) {`
32. `$(el).val(hex);`
33. `$(el).ColorPickerHide();`
34. `},`
35. `onBeforeShow: function () {`
36. `$(this).ColorPickerSetColor(this.value);`
37. `}`
38. `}).bind('keyup', function(){`
39. `$(this).ColorPickerSetColor(this.value);`
40. `});`
41. `</script>''' % name)`