Merge branch 'user-login-issues'

Fixes #6
This commit is contained in:
Santiago Lamora 2020-03-18 08:05:35 +01:00
commit 8ffe43d983
4 changed files with 28 additions and 3 deletions

View file

@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## master
- [changed] Include @pangea.org mail addresses (#4).
- [fixed] Error on login when user never has logged into the system (#6).
## [0.1] - 2020-01-29
- Login & logout methods using backend as auth method

View file

@ -2,7 +2,7 @@
Package metadata definition.
"""
VERSION = (0, 2, 0, 'alpha', 0)
VERSION = (0, 2, 0, 'alpha', 1)
def get_version():

View file

@ -120,8 +120,9 @@ class UserAccount(OrchestraModel):
if 'language' in data:
language = data['language'].lower()
if 'last_login' in data:
last_login = parse_datetime(data['last_login'])
last_login = data.get('last_login')
if last_login is not None:
last_login = parse_datetime(last_login)
return super().new_from_json(data=data, billing=billing, language=language, last_login=last_login)

View file

@ -39,6 +39,29 @@ class UserAccountTest(TestCase):
account = UserAccount.new_from_json(data)
self.assertIsNone(account.last_login)
def test_user_never_logged2(self):
# issue #6 Error on login when user never has logged into the system
data = {
'billcontact': {'address': 'bar',
'city': 'Barcelona',
'country': 'ES',
'name': '',
'vat': '12345678Z',
'zipcode': '34561'},
'date_joined': '2020-01-14T12:38:31Z',
'full_name': 'Pep',
'id': 2,
'is_active': True,
'language': 'CA',
'last_login': None,
'short_name': '',
'type': 'INDIVIDUAL',
'url': 'http://127.0.0.1:9090/api/accounts/2/',
'username': 'pepe'
}
account = UserAccount.new_from_json(data)
self.assertIsNone(account.last_login)
class GetBootstrapedPercentTest(TestCase):
BS_WIDTH = [0, 25, 50, 100]