[AIRFLOW-1078] Fix latest_runs endpoint for old flask versions

Old versions of flask (<0.11) dont support jsonify
on arrays due an
ECMAScript 4 vulnerability in older browsers. This
should work on old
flask versions as well.

Closes #2224 from saguziel/aguziel-fix-homepage


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

Branch: refs/heads/v1-8-test
Commit: 156e90b5c176633588fa7e5021de0185b583b8fc
Parents: 7002493
Author: Alex Guziel <[email protected]>
Authored: Fri Apr 7 19:26:35 2017 +0200
Committer: Maxime Beauchemin <[email protected]>
Committed: Thu Jun 8 08:36:20 2017 -0700

----------------------------------------------------------------------
 airflow/www/api/experimental/endpoints.py | 2 +-
 airflow/www/templates/airflow/dags.html   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/156e90b5/airflow/www/api/experimental/endpoints.py
----------------------------------------------------------------------
diff --git a/airflow/www/api/experimental/endpoints.py 
b/airflow/www/api/experimental/endpoints.py
index 63355c7..2dacd6c 100644
--- a/airflow/www/api/experimental/endpoints.py
+++ b/airflow/www/api/experimental/endpoints.py
@@ -130,4 +130,4 @@ def latest_dag_runs():
                 'dag_run_url': url_for('airflow.graph', dag_id=dagrun.dag_id,
                                        execution_date=dagrun.execution_date)
             })
-    return jsonify(payload)
+    return jsonify(items=payload) # old flask versions dont support jsonifying 
arrays

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/156e90b5/airflow/www/templates/airflow/dags.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/airflow/dags.html 
b/airflow/www/templates/airflow/dags.html
index e0546d6..16bbfb0 100644
--- a/airflow/www/templates/airflow/dags.html
+++ b/airflow/www/templates/airflow/dags.html
@@ -227,7 +227,7 @@
         });
       });
       $.getJSON("{{ url_for('api_experimental.latest_dag_runs') }}", 
function(data) {
-        $.each(data, function() {
+        $.each(data["items"], function() {
           var link = $("<a>", {
             href: this.dag_run_url,
             text: this.execution_date

Reply via email to