Ticket #11166: django-diff.txt

File django-diff.txt, 1.4 KB (added by Ludwig Pettersson, 15 years ago)

svn diff of patch

Line 
1Index: django/template/defaulttags.py
2===================================================================
3--- django/template/defaulttags.py (revision 10834)
4+++ django/template/defaulttags.py (working copy)
5@@ -409,7 +409,9 @@
6 value = float(value)
7 maxvalue = float(maxvalue)
8 ratio = (value / maxvalue) * max_width
9- except (ValueError, ZeroDivisionError):
10+ except ZeroDivisionError:
11+ return str(0)
12+ except ValueError:
13 return ''
14 return str(int(round(ratio)))
15
16Index: tests/regressiontests/templates/tests.py
17===================================================================
18--- tests/regressiontests/templates/tests.py (revision 10834)
19+++ tests/regressiontests/templates/tests.py (working copy)
20@@ -931,7 +931,7 @@
21
22 ### WIDTHRATIO TAG ########################################################
23 'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'),
24- 'widthratio02': ('{% widthratio a b 100 %}', {'a':0,'b':0}, ''),
25+ 'widthratio02': ('{% widthratio a b 100 %}', {'a':0,'b':0}, '0'),
26 'widthratio03': ('{% widthratio a b 100 %}', {'a':0,'b':100}, '0'),
27 'widthratio04': ('{% widthratio a b 100 %}', {'a':50,'b':100}, '50'),
28 'widthratio05': ('{% widthratio a b 100 %}', {'a':100,'b':100}, '100'),
Back to Top