def suit_django_version(): return utils.django_major_version()
import itertools from django import template from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import NoReverseMatch, reverse from django.db.models import ForeignKey from django.template.defaulttags import NowNode from django.utils.safestring import mark_safe from suit.config import get_config from suit import utils django_version = utils.django_major_version() try: # Django 1.9 from django.contrib.admin.utils import lookup_field except ImportError: from django.contrib.admin.util import lookup_field register = template.Library() @register.filter(name='suit_conf') def suit_conf(name): value = get_config(name) return mark_safe(value) if isinstance(value, str) else value @register.tag def suit_date(parser, token): return NowNode(get_config('HEADER_DATE_FORMAT'))
from django.contrib.admin.widgets import AdminTimeWidget, AdminDateWidget from django.forms import TextInput, Select, Textarea from django.utils.safestring import mark_safe from django import forms from django.utils.translation import ugettext as _ from django.templatetags.static import static from suit import utils django_version = utils.django_major_version() class NumberInput(TextInput): """ HTML5 Number input Left for backwards compatibility """ input_type = 'number' class HTML5Input(TextInput): """ Supports any HTML5 input http://www.w3schools.com/html/html5_form_input_types.asp """ def __init__(self, attrs=None, input_type=None): self.input_type = input_type super(HTML5Input, self).__init__(attrs) #
def test_suit_bc_value(self): args = [utils.django_major_version(), 'a'] self.assertEqual(utils.value_by_version(args), suit_bc_value(*args))
def test_django_major_version(self): self.assertEqual(utils.django_major_version(), float(get_version()[:3]))
def test_value_by_version(self): args = [utils.django_major_version(), 'a'] self.assertEqual(utils.value_by_version(args), 'a')