mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix: Date format when importing international timestamps (#25113)
This commit is contained in:
parent
e642361399
commit
00550d7c02
@ -1,142 +1,141 @@
|
|||||||
{#
|
{# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
Licensed to the Apache Software Foundation (ASF) under one
|
contributor license agreements. See the NOTICE file distributed with this work
|
||||||
or more contributor license agreements. See the NOTICE file
|
for additional information regarding copyright ownership. The ASF licenses this
|
||||||
distributed with this work for additional information
|
file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
regarding copyright ownership. The ASF licenses this file
|
use this file except in compliance with the License. You may obtain a copy of
|
||||||
to you under the Apache License, Version 2.0 (the
|
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
"License"); you may not use this file except in compliance
|
applicable law or agreed to in writing, software distributed under the License
|
||||||
with the License. You may obtain a copy of the License at
|
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the specific language
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
governing permissions and limitations under the License. #} {% extends
|
||||||
|
"appbuilder/base.html" %} {% import 'appbuilder/general/lib.html' as lib %} {%
|
||||||
Unless required by applicable law or agreed to in writing,
|
import "superset/macros.html" as macros %} {% set begin_sep_label = '
|
||||||
software distributed under the License is distributed on an
|
<td class="col-sm-2" style="border-left: 0; border-top: 0">
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
' %} {% set end_sep_label = '
|
||||||
KIND, either express or implied. See the License for the
|
</td>
|
||||||
specific language governing permissions and limitations
|
' %} {% set begin_sep_field = '
|
||||||
under the License.
|
<td style="border-right: 0; border-top: 0">' %} {% set end_sep_field = '</td>
|
||||||
#}
|
' %} {% import 'superset/form_view/database_schemas_selector.html' as
|
||||||
{% extends "appbuilder/base.html" %}
|
schemas_selector %} {% import 'superset/form_view/csv_scripts.html' as
|
||||||
{% import 'appbuilder/general/lib.html' as lib %}
|
csv_scripts %} {% import 'superset/form_view/csv_macros.html' as csv_macros %}
|
||||||
{% import "superset/macros.html" as macros %}
|
{% block content %} {{ lib.panel_begin(title, "edit") }}
|
||||||
{% set begin_sep_label = '<td class="col-sm-2" style="border-left: 0; border-top: 0;">' %}
|
|
||||||
{% set end_sep_label = '</td>' %}
|
|
||||||
{% set begin_sep_field = '<td style="border-right: 0; border-top: 0;">' %}
|
|
||||||
{% set end_sep_field = '</td>' %}
|
|
||||||
{% import 'superset/form_view/database_schemas_selector.html' as schemas_selector %}
|
|
||||||
{% import 'superset/form_view/csv_scripts.html' as csv_scripts %}
|
|
||||||
{% import 'superset/form_view/csv_macros.html' as csv_macros %}
|
|
||||||
{% block content %}
|
|
||||||
{{ lib.panel_begin(title, "edit") }}
|
|
||||||
<div id="Home" class="tab-pane active">
|
<div id="Home" class="tab-pane active">
|
||||||
<form id="model_form" action="" method="post" enctype="multipart/form-data">
|
<form id="model_form" action="" method="post" enctype="multipart/form-data">
|
||||||
{{form.hidden_tag()}}
|
{{form.hidden_tag()}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-12" style="padding: 0;">
|
<div class="col-md-12" style="padding: 0">
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
{{ lib.render_field(form.csv_file, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
|
{{ lib.render_field(form.csv_file, begin_sep_label, end_sep_label,
|
||||||
|
begin_sep_field, end_sep_field) }}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
{{ lib.render_field(form.table_name, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
|
{{ lib.render_field(form.table_name, begin_sep_label,
|
||||||
|
end_sep_label, begin_sep_field, end_sep_field) }}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
{{ lib.render_field(form.database, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
|
{{ lib.render_field(form.database, begin_sep_label, end_sep_label,
|
||||||
|
begin_sep_field, end_sep_field) }}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
{{ lib.render_field(form.schema, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
|
{{ lib.render_field(form.schema, begin_sep_label, end_sep_label,
|
||||||
|
begin_sep_field, end_sep_field) }}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
{{ csv_macros.render_delimiter_field(form.delimiter, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
|
{{ csv_macros.render_delimiter_field(form.delimiter,
|
||||||
|
begin_sep_label, end_sep_label, begin_sep_field, end_sep_field) }}
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% call csv_macros.render_collapsable_form_group("accordion1", "File Settings") %}
|
{% call csv_macros.render_collapsable_form_group("accordion1", "File
|
||||||
<tr>
|
Settings") %}
|
||||||
{{ lib.render_field(form.if_exists, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.if_exists, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.skip_initial_space, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.skip_initial_space, begin_sep_label,
|
||||||
</tr>
|
end_sep_label, begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.skip_blank_lines, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.skip_blank_lines, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.parse_dates, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.parse_dates, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.infer_datetime_format, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.infer_datetime_format, begin_sep_label,
|
||||||
</tr>
|
end_sep_label, begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.decimal, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.day_first, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.null_values, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.decimal, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
{% endcall %}
|
</tr>
|
||||||
{% call csv_macros.render_collapsable_form_group("accordion2", "Columns") %}
|
<tr>
|
||||||
<tr>
|
{{ lib.render_field(form.null_values, begin_sep_label, end_sep_label,
|
||||||
{{ lib.render_field(form.index_col, begin_sep_label, end_sep_label, begin_sep_field,
|
begin_sep_field, end_sep_field) }}
|
||||||
end_sep_field) }}
|
</tr>
|
||||||
</tr>
|
{% endcall %} {% call csv_macros.render_collapsable_form_group("accordion2",
|
||||||
<tr>
|
"Columns") %}
|
||||||
{{ lib.render_field(form.dataframe_index, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.index_col, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.index_label, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.dataframe_index, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.use_cols, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.index_label, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.overwrite_duplicate, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.use_cols, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.dtype, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.overwrite_duplicate, begin_sep_label,
|
||||||
</tr>
|
end_sep_label, begin_sep_field, end_sep_field) }}
|
||||||
{% endcall %}
|
</tr>
|
||||||
{% call csv_macros.render_collapsable_form_group("accordion3", "Rows") %}
|
<tr>
|
||||||
<tr>
|
{{ lib.render_field(form.dtype, begin_sep_label, end_sep_label,
|
||||||
{{ lib.render_field(form.header, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field)
|
begin_sep_field, end_sep_field) }}
|
||||||
}}
|
</tr>
|
||||||
</tr>
|
{% endcall %} {% call csv_macros.render_collapsable_form_group("accordion3",
|
||||||
<tr>
|
"Rows") %}
|
||||||
{{ lib.render_field(form.nrows, begin_sep_label, end_sep_label, begin_sep_field, end_sep_field)
|
<tr>
|
||||||
}}
|
{{ lib.render_field(form.header, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
<tr>
|
</tr>
|
||||||
{{ lib.render_field(form.skiprows, begin_sep_label, end_sep_label, begin_sep_field,
|
<tr>
|
||||||
end_sep_field) }}
|
{{ lib.render_field(form.nrows, begin_sep_label, end_sep_label,
|
||||||
</tr>
|
begin_sep_field, end_sep_field) }}
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
{{ lib.render_field(form.skiprows, begin_sep_label, end_sep_label,
|
||||||
|
begin_sep_field, end_sep_field) }}
|
||||||
|
</tr>
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-xs-12" style="padding: 0;">
|
<div class="col-xs-12" style="padding: 0">
|
||||||
{{ lib.render_form_controls() }}
|
{{ lib.render_form_controls() }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %} {% block add_tail_js %}
|
||||||
{% block add_tail_js %}
|
<script
|
||||||
<script src="{{url_for('appbuilder.static',filename='js/ab_keep_tab.js')}}" nonce="{{ macros.get_nonce() }}"></script>
|
src="{{url_for('appbuilder.static',filename='js/ab_keep_tab.js')}}"
|
||||||
{% endblock %}
|
nonce="{{ macros.get_nonce() }}"
|
||||||
{% block tail_js %}
|
></script>
|
||||||
{{ super() }}
|
{% endblock %} {% block tail_js %} {{ super() }} {{ schemas_selector }} {{
|
||||||
{{ schemas_selector }}
|
csv_scripts }} {% endblock %}
|
||||||
{{ csv_scripts }}
|
|
||||||
{% endblock %}
|
|
||||||
|
@ -201,6 +201,10 @@ class CsvToDatabaseForm(UploadToDatabaseForm):
|
|||||||
_("Interpret Datetime Format Automatically"),
|
_("Interpret Datetime Format Automatically"),
|
||||||
description=_("Interpret the datetime format automatically"),
|
description=_("Interpret the datetime format automatically"),
|
||||||
)
|
)
|
||||||
|
day_first = BooleanField(
|
||||||
|
_("Day First"),
|
||||||
|
description=_("DD/MM format dates, international and European format"),
|
||||||
|
)
|
||||||
decimal = StringField(
|
decimal = StringField(
|
||||||
_("Decimal Character"),
|
_("Decimal Character"),
|
||||||
default=".",
|
default=".",
|
||||||
|
@ -168,6 +168,7 @@ class CsvToDatabaseView(CustomFormView):
|
|||||||
form.skip_initial_space.data = False
|
form.skip_initial_space.data = False
|
||||||
form.skip_blank_lines.data = True
|
form.skip_blank_lines.data = True
|
||||||
form.infer_datetime_format.data = True
|
form.infer_datetime_format.data = True
|
||||||
|
form.day_first.data = False
|
||||||
form.decimal.data = "."
|
form.decimal.data = "."
|
||||||
form.if_exists.data = "fail"
|
form.if_exists.data = "fail"
|
||||||
|
|
||||||
@ -199,6 +200,7 @@ class CsvToDatabaseView(CustomFormView):
|
|||||||
header=form.header.data if form.header.data else 0,
|
header=form.header.data if form.header.data else 0,
|
||||||
index_col=form.index_col.data,
|
index_col=form.index_col.data,
|
||||||
infer_datetime_format=form.infer_datetime_format.data,
|
infer_datetime_format=form.infer_datetime_format.data,
|
||||||
|
dayfirst=form.day_first.data,
|
||||||
iterator=True,
|
iterator=True,
|
||||||
keep_default_na=not form.null_values.data,
|
keep_default_na=not form.null_values.data,
|
||||||
usecols=form.use_cols.data if form.use_cols.data else None,
|
usecols=form.use_cols.data if form.use_cols.data else None,
|
||||||
|
Loading…
Reference in New Issue
Block a user