Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Active at" column to user list. #3026

Merged
merged 31 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
88adadb
add last_active_at to users page
alison985 Sep 2, 2018
ddbdef8
Use our JSON encoder as the SQLAlchemy JSON serializer.
jezdez Oct 26, 2018
3ef2ebb
Fixed some inconsistencies in the user query class methods.
jezdez Oct 26, 2018
7295520
Minor cosmetic fixes.
jezdez Oct 26, 2018
f3f3ada
Add some make tasks for easier development.
jezdez Oct 29, 2018
fddc540
Add user detail sync system based on Redis backend.
jezdez Oct 29, 2018
3e23e9d
Normalize a few Flask extension API names.
jezdez Oct 29, 2018
1890760
Reduce implementation complexity of JSONEncoder.
jezdez Oct 29, 2018
ded899d
Use request_started signal to make sure we have a request context.
jezdez Oct 30, 2018
b485a16
Fix test that checks if disabled users can login.
jezdez Oct 30, 2018
6c3edce
Minor cosmetic fixes.
jezdez Oct 30, 2018
4ba039c
Remove needs_sync in favor of just deleting things.
jezdez Nov 8, 2018
412dd69
Misc review fixes.
jezdez Nov 13, 2018
d612a89
Ignore line length.
jezdez Nov 13, 2018
7f04a15
Split redash.models import several modules.
jezdez Nov 13, 2018
5237137
Split redash.models import several modules.
jezdez Dec 21, 2018
dcd16b9
Move walrus UTC DateTimeField into redash.models.types.
jezdez Nov 13, 2018
6301bfa
Restore distinctly loading dashboards.
jezdez Nov 14, 2018
4281ee9
Simplify default values for user details.
jezdez Nov 14, 2018
4bb782e
Define __repr__ methods generically.
jezdez Nov 15, 2018
10a4e6f
Consistently have underscore methods at the top of model methods.
jezdez Nov 15, 2018
9b54cbf
Fix tests.
jezdez Nov 15, 2018
bd2ed51
Update to latest walrus and redis-py.
jezdez Nov 20, 2018
d55b976
Update kombu to 4.2.2 for redis-py 3.x compatibility.
jezdez Dec 18, 2018
c0bed65
Remove redis-cli container after running Make task.
jezdez Dec 18, 2018
dc196e8
Move buffer condition after datetime/time conditions.
jezdez Dec 18, 2018
0724785
Update walrus to 0.7.1.
jezdez Dec 18, 2018
2bd55bf
Refactor some query APIs.
jezdez Dec 19, 2018
6bf3621
Post rebase fixes.
arikfr Jan 6, 2019
cde74f0
Use correct kombu version
arikfr Jan 6, 2019
392bb8d
Fix migration down revision
arikfr Jan 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: compose_build up test_db create_database clean down bundle tests lint backend-unit-tests frontend-unit-tests test build watch start
.PHONY: compose_build up test_db create_database clean down bundle tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash

compose_build:
docker-compose build
Expand Down Expand Up @@ -49,3 +49,9 @@ watch: bundle

start: bundle
npm run start

redis-cli:
docker-compose run --rm redis redis-cli -h redis

bash:
docker-compose run --rm server bash
7 changes: 7 additions & 0 deletions client/app/pages/users/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
Joined
<sort-icon column="'created_at'" sort-column="$ctrl.paginator.orderByField" reverse="$ctrl.paginator.orderByReverse"></sort-icon>
</th>
<th class="sortable-column" ng-click="$ctrl.paginator.orderBy('active_at')">
Last Active At
<sort-icon column="'active_at'" sort-column="$ctrl.paginator.orderByField" reverse="$ctrl.paginator.orderByReverse"></sort-icon>
</th>
<th width="1%"></th>
</tr>
</thead>
Expand All @@ -62,6 +66,9 @@
<td>
<span am-time-ago="user.created_at"></span>
</td>
<td>
<span am-time-ago="user.active_at" uib-tooltop="user.active_at"></span>
</td>
<td>
<div ng-if="$ctrl.currentUser.hasPermission('admin') && (user.id != $ctrl.currentUser.id)">
<button type="button" class="btn btn-primary" ng-if="user.is_disabled" ng-click="$ctrl.enableUser(user)">Enable</button>
Expand Down
24 changes: 24 additions & 0 deletions migrations/versions/e7f8a917aa8e_add_user_details_json_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Add user details JSON column.

Revision ID: e7f8a917aa8e
Revises: 71477dadd6ef
Create Date: 2018-11-08 16:12:17.023569

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'e7f8a917aa8e'
down_revision = '640888ce445d'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('users', sa.Column('details', postgresql.JSON(astext_type=sa.Text()), server_default='{}', nullable=True))


def downgrade():
op.drop_column('users', 'details')
21 changes: 11 additions & 10 deletions redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging
import urlparse
import urllib
import redis

import walrus
from flask import Flask, current_app
from flask_sslify import SSLify
from werkzeug.contrib.fixers import ProxyFix
Expand Down Expand Up @@ -47,21 +48,22 @@ def create_redis_connection():
else:
db = 0

r = redis.StrictRedis(unix_socket_path=redis_url.path, db=db)
client = walrus.Database(unix_socket_path=redis_url.path, db=db)
else:
if redis_url.path:
redis_db = redis_url.path[1]
else:
redis_db = 0
# Redis passwords might be quoted with special characters
redis_password = redis_url.password and urllib.unquote(redis_url.password)
r = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)
client = walrus.Database(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)

return r
return client


setup_logging()
redis_connection = create_redis_connection()

mail = Mail()
migrate = Migrate()
mail.init_mail(settings.all_settings())
Expand Down Expand Up @@ -90,12 +92,10 @@ def to_url(self, value):


def create_app(load_admin=True):
from redash import extensions, handlers
from redash import admin, authentication, extensions, handlers
from redash.handlers.webpack import configure_webpack
from redash.handlers import chrome_logger
from redash.admin import init_admin
from redash.models import db
from redash.authentication import setup_authentication
from redash.models import db, users
from redash.metrics.request import provision_app

app = Flask(__name__,
Expand Down Expand Up @@ -131,14 +131,15 @@ def create_app(load_admin=True):
db.init_app(app)
migrate.init_app(app, db)
if load_admin:
init_admin(app)
admin.init_admin(app)
mail.init_app(app)
setup_authentication(app)
authentication.init_app(app)
jezdez marked this conversation as resolved.
Show resolved Hide resolved
limiter.init_app(app)
handlers.init_app(app)
configure_webpack(app)
extensions.init_extensions(app)
chrome_logger.init_app(app)
users.init_app(app)

return app

Expand Down
4 changes: 2 additions & 2 deletions redash/authentication/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def hmac_load_user_from_request(request):
return user

if query_id:
query = models.db.session.query(models.Query).filter(models.Query.id == query_id).one()
query = models.Query.query.filter(models.Query.id == query_id).one()
calculated_signature = sign(query.api_key, request.path, expires)

if query.api_key and signature == calculated_signature:
Expand Down Expand Up @@ -238,7 +238,7 @@ def logout_and_redirect_to_index():
return redirect(index_url)


def setup_authentication(app):
def init_app(app):
from redash.authentication import google_oauth, saml_auth, remote_user_auth, ldap_auth

login_manager.init_app(app)
Expand Down
2 changes: 1 addition & 1 deletion redash/handlers/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@login_required
def organization_status(org_slug=None):
counters = {
'users': models.User.all_not_disabled(current_org).count(),
'users': models.User.all(current_org).count(),
arikfr marked this conversation as resolved.
Show resolved Hide resolved
'alerts': models.Alert.all(group_ids=current_user.group_ids).count(),
'data_sources': models.DataSource.all(current_org, group_ids=current_user.group_ids).count(),
'queries': models.Query.all_queries(current_user.group_ids, current_user.id, drafts=True).count(),
Expand Down
2 changes: 2 additions & 0 deletions redash/handlers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
order_map = {
'name': 'name',
'-name': '-name',
'active_at': 'active_at',
'-active_at': '-active_at',
'created_at': 'created_at',
'-created_at': '-created_at',
'groups': 'group_ids',
Expand Down
Loading