Repository: getredash/redash

Issue:
Users who are already disabled still appear on CLI
<!--
#####################################################################
#
# Need support? USE THE FORUM! https://discuss.redash.io/c/support.
#
# Don't have steps to reproduce and actually not sure it's a bug?
# Use the forum! https://discuss.redash.io/c/support.
#
#####################################################################

**Got an idea for a new feature?** Check if it isn't on the roadmap already: http://bit.ly/redash-roadmap and start a new discussion in the features category: https://discuss.redash.io/c/feature-requests 🌟.

Found a bug? Please fill out the sections below... thank you 👍

Found a security vulnerability? Please email security@redash.io to report any security vulnerabilities. We will acknowledge receipt of your vulnerability and strive to send you regular updates about our progress. If you're curious about the status of your disclosure please feel free to email us again. If you want to encrypt your disclosure email, you can use this PGP key.

-->

### Issue Summary

When I refer to user list on redash cli.
Even I made some user disabled, the user is still existed on the list.

### Steps to Reproduce

``` docker exec -it redash_server_1 ./manage.py users list ```

```
Id: 2
Name: sumito
Email: sute@sumito.jp
Organization: sumito
--------------------
```
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

### Technical details:

* Redash Version: 5.0.1+b4850
* Browser/OS: Chrome
* How did you install Redash: docker
Users who are already disabled still appear on CLI
<!--
#####################################################################
#
# Need support? USE THE FORUM! https://discuss.redash.io/c/support.
#
# Don't have steps to reproduce and actually not sure it's a bug?
# Use the forum! https://discuss.redash.io/c/support.
#
#####################################################################

**Got an idea for a new feature?** Check if it isn't on the roadmap already: http://bit.ly/redash-roadmap and start a new discussion in the features category: https://discuss.redash.io/c/feature-requests 🌟.

Found a bug? Please fill out the sections below... thank you 👍

Found a security vulnerability? Please email security@redash.io to report any security vulnerabilities. We will acknowledge receipt of your vulnerability and strive to send you regular updates about our progress. If you're curious about the status of your disclosure please feel free to email us again. If you want to encrypt your disclosure email, you can use this PGP key.

-->

### Issue Summary

When I refer to user list on redash cli.
Even I made some user disabled, the user is still existed on the list.

### Steps to Reproduce

``` docker exec -it redash_server_1 ./manage.py users list ```

```
Id: 2
Name: sumito
Email: sute@sumito.jp
Organization: sumito
--------------------
```
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

### Technical details:

* Redash Version: 5.0.1+b4850
* Browser/OS: Chrome
* How did you install Redash: docker


Discussion:

Resolving patch:
diff --git a/redash/cli/users.py b/redash/cli/users.py
--- a/redash/cli/users.py
+++ b/redash/cli/users.py
@@ -245,5 +245,5 @@ def list(organization=None):
         if i > 0:
             print("-" * 20)
 
-        print("Id: {}\nName: {}\nEmail: {}\nOrganization: {}".format(
-            user.id, user.name.encode('utf-8'), user.email, user.org.name))
+        print("Id: {}\nName: {}\nEmail: {}\nOrganization: {}\nActive: {}".format(
+            user.id, user.name.encode('utf-8'), user.email, user.org.name, not(user.is_disabled)))


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -391,6 +391,7 @@ def test_list(self):
         Name: Fred Foobar
         Email: foobar@example.com
         Organization: Default
+        Active: True
         """
         self.assertMultiLineEqual(result.output,
                                   textwrap.dedent(output).lstrip())