Coverage for cas_server/templatetags/cas_server.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-18 09:41 +0000

1# This program is distributed in the hope that it will be useful, but WITHOUT 

2# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 

3# FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for 

4# more details. 

5# 

6# You should have received a copy of the GNU General Public License version 3 

7# along with this program; if not, write to the Free Software Foundation, Inc., 51 

8# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 

9# 

10# (c) 2015-2016 Valentin Samir 

11"""template tags for the app""" 

12from django import template 

13from django import forms 

14 

15register = template.Library() 

16 

17 

18@register.filter(name='is_checkbox') 

19def is_checkbox(field): 

20 """ 

21 check if a form bound field is a checkbox 

22 

23 :param django.forms.BoundField field: A bound field 

24 :return: ``True`` if the field is a checkbox, ``False`` otherwise. 

25 :rtype: bool 

26 """ 

27 return isinstance(field.field.widget, forms.CheckboxInput) 

28 

29 

30@register.filter(name='is_hidden') 

31def is_hidden(field): 

32 """ 

33 check if a form bound field is hidden 

34 

35 :param django.forms.BoundField field: A bound field 

36 :return: ``True`` if the field is hidden, ``False`` otherwise. 

37 :rtype: bool 

38 """ 

39 return isinstance(field.field.widget, forms.HiddenInput)