Skip to content

Commit

Permalink
Merge pull request #113 from gaiaresources/fix_profile_create
Browse files Browse the repository at this point in the history
Fix profile create
  • Loading branch information
tony-gaia committed Oct 11, 2016
2 parents 8350a9a + 90c932c commit ac23b87
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
global:
- SECRET_KEY=SecretKeyForTravis
- DATABASE_URL="postgis://postgres@localhost:5432/travis_ci_test"
- DEFAULT_HOST="wildlifelicensing"
install:
- pip install -r requirements.txt
- pip install coveralls
Expand Down
4 changes: 2 additions & 2 deletions wildlifelicensing/apps/applications/views/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def get_context_data(self, **kwargs):
initial_email=application.applicant.email,
user=application.applicant)

kwargs['address_form'] = AddressForm()
kwargs['address_form'] = AddressForm(user=application.applicant)

return super(CreateSelectProfileView, self).get_context_data(**kwargs)

Expand All @@ -400,7 +400,7 @@ def post(self, request, *args, **kwargs):
return render(request, self.template_name, {'licence_type': application.licence_type,
'profile_selection_form': profile_selection_form,
'profile_creation_form': ProfileForm(),
'address_form': AddressForm()})
'address_form': AddressForm(user=application.applicant)})
elif 'create' in request.POST:
profile_form = ProfileForm(request.POST)
address_form = AddressForm(request.POST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def get_context_data(self, **kwargs):
kwargs['address_form'] = AddressForm(instance=profile.postal_address)
else:
kwargs['profile_form'] = ProfileForm(user=customer)
kwargs['address_form'] = AddressForm()
kwargs['address_form'] = AddressForm(user=customer)

return super(EditProfileView, self).get_context_data(**kwargs)

Expand Down
5 changes: 3 additions & 2 deletions wildlifelicensing/apps/main/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from openpyxl.worksheet.datavalidation import DataValidation
from openpyxl.utils import get_column_letter

from django.utils import six
from django.utils.text import Truncator
from django.http import HttpResponse

Expand Down Expand Up @@ -62,7 +63,7 @@ def is_blank_value(value):


def is_empty_string(value):
return isinstance(value, basestring) and len(value.strip()) == 0
return isinstance(value, six.string_types) and len(value.strip()) == 0


def is_cell_blank(cell):
Expand All @@ -74,7 +75,7 @@ def is_all_blanks(cells):


def strip(value):
return value.strip() if isinstance(value, basestring) else value
return value.strip() if isinstance(value, six.string_types) else value


def get_value_for_key(ws, key, direction='down'):
Expand Down
3 changes: 2 additions & 1 deletion wildlifelicensing/apps/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from datetime import datetime

from django.utils import six
from django import forms
from django.contrib.postgres.forms import JSONField
from django.forms.widgets import SelectMultiple
Expand All @@ -26,7 +27,7 @@ def __init__(self, **kwargs):
def prepare_value(self, value):
if value is None:
return ""
if isinstance(value, basestring):
if isinstance(value, six.string_types):
# already a string
return value
else:
Expand Down
6 changes: 3 additions & 3 deletions wildlifelicensing/apps/returns/utils_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from openpyxl import Workbook
from openpyxl.styles import Font
from openpyxl.writer.write_only import WriteOnlyCell

from django.utils import six
from django.utils.encoding import python_2_unicode_compatible

from wildlifelicensing.apps.main.excel import is_blank_value
Expand Down Expand Up @@ -50,9 +50,9 @@ def cast(self, value):
if is_blank_value(value):
# must do that because an empty string is considered as valid even if required by the StringType
value = None
if isinstance(value, basestring):
if isinstance(value, six.string_types) and not isinstance(value, six.text_type):
# the StringType accepts only unicode
value = unicode(value)
value = six.u(value)
return self.type.cast(value)

def validate(self, value):
Expand Down

0 comments on commit ac23b87

Please sign in to comment.