Fixing email and datepicker, upgrading to latest flask-admin with bootstrap 3

This commit is contained in:
Maxime 2014-12-20 22:27:14 +00:00
Родитель beca062442
Коммит 55a9bb8723
4 изменённых файлов: 24 добавлений и 22 удалений

Просмотреть файл

@ -531,14 +531,20 @@ class TaskInstance(Base):
self.end_date = datetime.now()
self.set_duration()
session.add(Log(State.FAILED, self))
if self.try_number <= task.retries:
self.state = State.UP_FOR_RETRY
if task.email_on_retry and task.email:
self.email_alert(e, is_retry=True)
else:
self.state = State.FAILED
if task.email_on_failure and task.email:
self.email_alert(e, is_retry=False)
# Let's go deeper
try:
if self.try_number <= task.retries:
self.state = State.UP_FOR_RETRY
if task.email_on_retry and task.email:
self.email_alert(e, is_retry=True)
else:
self.state = State.FAILED
if task.email_on_failure and task.email:
self.email_alert(e, is_retry=False)
except Exception as e2:
logging.error('Failed to send email to: ' + task.email)
session.merge(self)
session.commit()
logging.error(str(e))

Просмотреть файл

@ -5,6 +5,7 @@ import logging
from flask import Flask, url_for, Markup, Blueprint, redirect, flash
from flask.ext.admin import Admin, BaseView, expose, AdminIndexView
from flask.ext.admin.form import DateTimePickerWidget
from flask.ext.admin import base
from flask.ext.admin.contrib.sqla import ModelView
from flask import request
@ -44,11 +45,11 @@ app.jinja_env.add_extension("chartkick.ext.charts")
# Date filter form needed for gantt and graph view
class DateTimeForm(Form):
execution_date = DateTimeField("Execution date")
execution_date = DateTimeField("Execution date", widget=DateTimePickerWidget())
class GraphForm(Form):
execution_date = DateTimeField("Execution date")
execution_date = DateTimeField("Execution date", widget=DateTimePickerWidget())
arrange = SelectField("Layout", choices=(
('LR', "Left->Right"),
('RL', "Right->Left"),
@ -725,7 +726,7 @@ def duration_f(v, c, m, p):
if m.end_date:
return timedelta(seconds=m.duration)
class TaskInstanceModelView(ModelViewOnly):
class TaskInstanceModelView(ModelView):
column_filters = ('dag_id', 'task_id', 'state', 'execution_date')
column_formatters = dict(
log=log_link, task_id=task_link, dag_id=dag_link, duration=duration_f)

Просмотреть файл

@ -2,7 +2,7 @@
{% block head_css %}
{{ super() }}
<link href="{{ admin_static.url(filename='datetimepicker/bootstrap-datetimepicker.css') }}" rel="stylesheet">
<link href="{{ admin_static.url(filename='vendor/bootstrap-daterangepicker/daterangepicker-bs2.css') }}" rel="stylesheet">
{% endblock %}
{% block body %}
@ -22,7 +22,8 @@
<script src="{{ url_for('static', filename='highcharts-more.js') }}">
</script>
<script src="{{ admin_static.url(
filename='datetimepicker/bootstrap-datetimepicker.js') }}"></script>
filename='vendor/bootstrap-daterangepicker/daterangepicker.js') }}"></script>
<script src="{{ admin_static.url(filename='admin/js/form-1.0.0.js') }}"></script>
<script>
execution_date = '{{ execution_date }}';
hc = {{ hc|safe }};
@ -46,9 +47,6 @@
}
}
$('#container').highcharts(hc);
// Activating the date time picker widget
$('#execution_date').datetimepicker();
</script>
{% endblock %}

Просмотреть файл

@ -10,7 +10,7 @@
href="{{ url_for('static', filename='dagre.css') }}">
<link rel="stylesheet" type="text/css"
href="{{ url_for('static', filename='graph.css') }}">
<link href="{{ admin_static.url(filename='datetimepicker/bootstrap-datetimepicker.css') }}" rel="stylesheet">
<link href="{{ admin_static.url(filename='vendor/bootstrap-daterangepicker/daterangepicker-bs2.css') }}" rel="stylesheet">
{% endblock %}
{% block body %}
@ -37,8 +37,8 @@
<script src="{{ url_for('static', filename='d3.v3.min.js') }}"></script>
<script src="{{ url_for('static', filename='dagre-d3.min.js') }}"></script>
<script src="{{ admin_static.url(
filename='datetimepicker/bootstrap-datetimepicker.js') }}"></script>
<script src="{{ admin_static.url(filename='admin/js/form.js') }}"></script>
filename='vendor/bootstrap-daterangepicker/daterangepicker.js') }}"></script>
<script src="{{ admin_static.url(filename='admin/js/form-1.0.0.js') }}"></script>
<script>
var nodes = {{ nodes|safe }};
var edges = {{ edges|safe }};
@ -52,9 +52,6 @@
var renderer = new dagreD3.Renderer();
renderer.layout(layout).run(g, d3.select("#dig"));
// Activating the date time picker widget
$('#execution_date').datetimepicker();
// Assigning css classes based on state to nodes for border coloring
$.each(task_instances, function(task_id, ti) {
$('tspan').filter(function(index) { return $(this).text() === task_id; })