Repository: incubator-airflow
Updated Branches:
  refs/heads/master 3a6cdc865 -> 86d096004


[AIRFLOW-2504] Log username correctly and add extra to search columns

Closes #3438 from youngyjd/log-username-old-ui


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/86d09600
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/86d09600
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/86d09600

Branch: refs/heads/master
Commit: 86d096004282e6367cb7f4158652f0784b498d0e
Parents: 3a6cdc8
Author: Junda Yang <[email protected]>
Authored: Fri Jun 1 15:06:24 2018 -0700
Committer: Joy Gao <[email protected]>
Committed: Fri Jun 1 15:06:30 2018 -0700

----------------------------------------------------------------------
 airflow/www/templates/admin/master.html | 10 +++++++---
 airflow/www/utils.py                    |  5 +++--
 airflow/www/views.py                    |  2 +-
 airflow/www_rbac/views.py               |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/86d09600/airflow/www/templates/admin/master.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/admin/master.html 
b/airflow/www/templates/admin/master.html
index cb1e9f1..2939a09 100644
--- a/airflow/www/templates/admin/master.html
+++ b/airflow/www/templates/admin/master.html
@@ -5,9 +5,9 @@
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
-  
+
     http://www.apache.org/licenses/LICENSE-2.0
-  
+
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -64,7 +64,11 @@
           <a class="navbar-brand" rel="home" href="{{ url_for('admin.index') 
}}" style="cursor: pointer;">
               <img style="float: left; width:35px; margin-top: -7px;"
                    src="{{ url_for("static", filename="pin_100.png") }}"
-                   title="{{ current_user.username }}">
+                   {% if current_user.user is defined %}
+                      title="{{ current_user.user.username }}"
+                   {% else %}
+                      title="{{ current_user.username }}"
+                   {% endif %}>
               <span>Airflow</span>
           </a>
       </div>

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/86d09600/airflow/www/utils.py
----------------------------------------------------------------------
diff --git a/airflow/www/utils.py b/airflow/www/utils.py
index 755a9e2..7d9c8a0 100644
--- a/airflow/www/utils.py
+++ b/airflow/www/utils.py
@@ -246,8 +246,9 @@ def action_logging(f):
     """
     @functools.wraps(f)
     def wrapper(*args, **kwargs):
-        if current_user and hasattr(current_user, 'username'):
-            user = current_user.username
+        # Only AnonymousUserMixin() does not have user attribute
+        if current_user and hasattr(current_user, 'user'):
+            user = current_user.user.username
         else:
             user = 'anonymous'
 

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/86d09600/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 284f7e9..3d09670 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -2591,7 +2591,7 @@ class LogModelView(ModelViewOnly):
     verbose_name = "log"
     column_display_actions = False
     column_default_sort = ('dttm', True)
-    column_filters = ('dag_id', 'task_id', 'execution_date')
+    column_filters = ('dag_id', 'task_id', 'execution_date', 'extra')
     filter_converter = wwwutils.UtcFilterConverter()
     column_formatters = dict(
         dttm=datetime_f, execution_date=datetime_f, dag_id=dag_link)

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/86d09600/airflow/www_rbac/views.py
----------------------------------------------------------------------
diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index 6f3d650..e09c384 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -1974,7 +1974,7 @@ class LogModelView(AirflowModelView):
 
     list_columns = ['id', 'dttm', 'dag_id', 'task_id', 'event', 
'execution_date',
                     'owner', 'extra']
-    search_columns = ['dag_id', 'task_id', 'execution_date']
+    search_columns = ['dag_id', 'task_id', 'execution_date', 'extra']
 
     base_order = ('dttm', 'desc')
 

Reply via email to