python 3 fixes

This commit is contained in:
aarif
2019-09-26 18:08:06 +05:00
parent 3c02969a99
commit eb694a71b8

View File

@@ -2,6 +2,9 @@
Forms for the password policy app.
"""
from __future__ import absolute_import
import six
from django.contrib import messages
from django.contrib.admin.forms import AdminAuthenticationForm
from django.forms import ValidationError
@@ -25,9 +28,9 @@ class PasswordPolicyAwareAdminAuthForm(AdminAuthenticationForm):
password_policy_compliance.enforce_compliance_on_login(self.user_cache, cleaned_data['password'])
except password_policy_compliance.NonCompliantPasswordWarning as e:
# Allow login, but warn the user that they will be required to reset their password soon.
messages.warning(self.request, e.message)
messages.warning(self.request, six.text_type(e))
except password_policy_compliance.NonCompliantPasswordException as e:
# Prevent the login attempt.
raise ValidationError(e.message)
raise ValidationError(six.text_type(e))
return cleaned_data