From 324b6171888bce14a58d437151efdf1a36cecd19 Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 12 Dec 2018 11:42:54 -0800 Subject: [PATCH] Follow-up Fixes (#767) Found a couple of issues by the previous fix. So this is to fix those. Changelog: Fixed logout If a user has multiple records of the same role, it should no longer make the checkbox unclickable Removed validation from Phones as it's causing confusing behaviour --- .../api/migrations/0047_auto_20181205_1716.py | 25 +++++++++++++++++++ backend/api/models/User.py | 8 ++---- frontend/src/admin/users/UserEditContainer.js | 12 +++++++++ frontend/src/app/components/Navbar.js | 8 +++--- rmconfig.json | 5 ++++ 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 backend/api/migrations/0047_auto_20181205_1716.py create mode 100644 rmconfig.json diff --git a/backend/api/migrations/0047_auto_20181205_1716.py b/backend/api/migrations/0047_auto_20181205_1716.py new file mode 100644 index 000000000..f892878f6 --- /dev/null +++ b/backend/api/migrations/0047_auto_20181205_1716.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-12-05 17:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0046_document_data_load'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='cell_phone', + field=models.CharField(blank=True, max_length=17, null=True), + ), + migrations.AlterField( + model_name='user', + name='phone', + field=models.CharField(blank=True, max_length=17, null=True), + ), + ] diff --git a/backend/api/models/User.py b/backend/api/models/User.py index 403fb4eb6..20a9a1b17 100644 --- a/backend/api/models/User.py +++ b/backend/api/models/User.py @@ -48,10 +48,6 @@ class User(AbstractUser, Auditable): verbose_name='username', db_comment='Login Username' ) - phone_regex = RegexValidator( - regex=r'^\+?1?\d{9,15}$', - message="Phone number must be entered in the " - "format: '+999999999'. Up to 15 digits allowed.") password = models.CharField( max_length=128, blank=True, null=True, db_comment='Password hash') @@ -61,10 +57,10 @@ class User(AbstractUser, Auditable): title = models.CharField( max_length=100, blank=True, null=True, db_comment='Professional Title') phone = models.CharField( - validators=[phone_regex], max_length=17, blank=True, null=True, + max_length=17, blank=True, null=True, db_comment='Primary phone number') cell_phone = models.CharField( - validators=[phone_regex], max_length=17, blank=True, null=True, + max_length=17, blank=True, null=True, db_comment='Mobile phone number') organization = models.ForeignKey( 'Organization', related_name='users', blank=True, null=True, diff --git a/frontend/src/admin/users/UserEditContainer.js b/frontend/src/admin/users/UserEditContainer.js index 03963d455..648c049dd 100644 --- a/frontend/src/admin/users/UserEditContainer.js +++ b/frontend/src/admin/users/UserEditContainer.js @@ -166,6 +166,18 @@ class UserEditContainer extends Component { fieldState.roles[index].value = !fieldState.roles[index].value; } + // search for duplicates and get rid of them. they should be very unlikely, but just in case + const indexesFound = []; + fieldState.roles.forEach((role) => { + if (role.id === key) { + indexesFound.push(role); + } + }); + + if (indexesFound.length > 1) { + fieldState.roles.splice(index, 1); + } + this.setState({ fields: fieldState }); diff --git a/frontend/src/app/components/Navbar.js b/frontend/src/app/components/Navbar.js index 262974fb0..70abaa68e 100644 --- a/frontend/src/app/components/Navbar.js +++ b/frontend/src/app/components/Navbar.js @@ -268,7 +268,7 @@ class Navbar extends Component { {CONFIG.KEYCLOAK.ENABLED && { e.preventDefault(); this.props.dispatch(signUserOut()); }} + onClick={(e) => { e.preventDefault(); this.props.signUserOut(); }} to={Routes.LOGOUT} > Log Out @@ -364,7 +364,7 @@ class Navbar extends Component { {CONFIG.KEYCLOAK.ENABLED && { - e.preventDefault(); this.props.dispatch(signUserOut()); + e.preventDefault(); this.props.signUserOut(); }} > Log Out @@ -416,11 +416,13 @@ Navbar.propTypes = { id: PropTypes.number })) }).isRequired, + signUserOut: PropTypes.func.isRequired, unreadNotificationsCount: PropTypes.number }; const mapDispatchToProps = dispatch => ({ - getNotifications: bindActionCreators(getNotifications, dispatch) + getNotifications: bindActionCreators(getNotifications, dispatch), + signUserOut: bindActionCreators(signUserOut, dispatch) }); // export default Navbar; diff --git a/rmconfig.json b/rmconfig.json new file mode 100644 index 000000000..44df88129 --- /dev/null +++ b/rmconfig.json @@ -0,0 +1,5 @@ +{ + "pullRequest": { + "maxLinesChanged": 1000 + } +} \ No newline at end of file