Remove dependency over six
This commit is contained in:
@@ -3,14 +3,21 @@
|
||||
with jSignature jQuery plugin
|
||||
"""
|
||||
import json
|
||||
import six
|
||||
|
||||
from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from .forms import (
|
||||
JSignatureField as JSignatureFormField,
|
||||
JSIGNATURE_EMPTY_VALUES)
|
||||
JSIGNATURE_EMPTY_VALUES,
|
||||
)
|
||||
|
||||
try:
|
||||
from django.utils import six
|
||||
string_types = six.string_types
|
||||
except ImportError:
|
||||
string_types = str
|
||||
|
||||
|
||||
|
||||
class JSignatureField(models.Field):
|
||||
@@ -39,7 +46,7 @@ class JSignatureField(models.Field):
|
||||
def get_prep_value(self, value):
|
||||
if value in JSIGNATURE_EMPTY_VALUES:
|
||||
return None
|
||||
elif isinstance(value, six.string_types):
|
||||
elif isinstance(value, string_types):
|
||||
return value
|
||||
elif isinstance(value, list):
|
||||
return json.dumps(value)
|
||||
@@ -49,9 +56,3 @@ class JSignatureField(models.Field):
|
||||
defaults = {'form_class': JSignatureFormField}
|
||||
defaults.update(kwargs)
|
||||
return super(JSignatureField, self).formfield(**defaults)
|
||||
|
||||
try:
|
||||
from south.modelsinspector import add_introspection_rules
|
||||
add_introspection_rules([], ["jsignature.fields.JSignatureField"])
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
with jSignature jQuery plugin
|
||||
"""
|
||||
import json
|
||||
import six
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from django.forms.widgets import HiddenInput
|
||||
@@ -17,6 +16,13 @@ from jsignature.settings import JSIGNATURE_DEFAULT_CONFIG
|
||||
JSIGNATURE_EMPTY_VALUES = validators.EMPTY_VALUES + ('[]', )
|
||||
|
||||
|
||||
try:
|
||||
from django.utils import six
|
||||
string_types = six.string_types
|
||||
except ImportError:
|
||||
string_types = str
|
||||
|
||||
|
||||
class JSignatureWidget(HiddenInput):
|
||||
"""
|
||||
A widget handling a signature capture field with with jSignature
|
||||
@@ -54,7 +60,7 @@ class JSignatureWidget(HiddenInput):
|
||||
""" Prepare value before effectively render widget """
|
||||
if value in JSIGNATURE_EMPTY_VALUES:
|
||||
return "[]"
|
||||
elif isinstance(value, six.string_types):
|
||||
elif isinstance(value, string_types):
|
||||
return value
|
||||
elif isinstance(value, list):
|
||||
return json.dumps(value)
|
||||
|
||||
Reference in New Issue
Block a user