Skip to content

Commit

Permalink
Python 3 fixes for fields/forms
Browse files Browse the repository at this point in the history
This isn't intended to be exhaustive, I just fixed what I needed.
  • Loading branch information
julianandrews committed Oct 14, 2015
1 parent 8ed4374 commit d6b9479
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fusionbox/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import calendar
import datetime
import re
import six
from functools import partial

import phonenumbers
Expand Down Expand Up @@ -243,7 +244,7 @@ def __init__(self, *args, **kwargs):
super(CCNumberField, self).__init__(*args, **kwargs)

def clean(self, value):
if isinstance(value, basestring):
if isinstance(value, six.string_types):
value = re.sub('\D', '', value)
number = super(CCNumberField, self).clean(value)
return number
10 changes: 7 additions & 3 deletions fusionbox/forms/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import StringIO
import copy
import csv
import urllib

try:
from StringIO import StringIO
except ImportError:
from io import StringIO

from django import forms
from django.core.exceptions import ValidationError
from django.forms.util import ErrorList, ErrorDict
Expand Down Expand Up @@ -345,7 +349,7 @@ def pre_sort(self, qs):
"""
Hook for doing pre-sort modification of the queryset.
Runs regardless
Runs regardless
"""
return qs

Expand Down Expand Up @@ -656,7 +660,7 @@ def csv_content(self):
csv_data.append([unicode(csv_getvalue(obj, column)).encode('utf-8') for column in csv_columns])

# Create buffer with csv content
content = StringIO.StringIO()
content = StringIO()
writer = csv.writer(content)
writer.writerow(csv_headers)
writer.writerows(csv_data)
Expand Down

0 comments on commit d6b9479

Please sign in to comment.