Exemple #1
0
def suit_django_version():
    return utils.django_major_version()
Exemple #2
0
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'))
Exemple #3
0
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)


#
Exemple #4
0
 def test_suit_bc_value(self):
     args = [utils.django_major_version(), 'a']
     self.assertEqual(utils.value_by_version(args), suit_bc_value(*args))
Exemple #5
0
 def test_django_major_version(self):
     self.assertEqual(utils.django_major_version(),
                      float(get_version()[:3]))
Exemple #6
0
 def test_django_major_version(self):
     self.assertEqual(utils.django_major_version(), float(get_version()[:3]))
Exemple #7
0
 def test_value_by_version(self):
     args = [utils.django_major_version(), 'a']
     self.assertEqual(utils.value_by_version(args), 'a')
Exemple #8
0
def suit_django_version():
    return utils.django_major_version()