Skip to content
Snippets Groups Projects
Commit 49e1d998 authored by anonymous's avatar anonymous
Browse files

fix erro date handling date range search

parent d8d36fee
No related branches found
No related tags found
No related merge requests found
......@@ -105,11 +105,15 @@ def odsh_get_spatial_text(pkg_dict):
return None
def odsh_render_datetime(datetime_, date_format='{0.day:02d}.{0.month:02d}.{0.year:4d}'):
def odsh_render_datetime(datetime_, fromIso=True):
date_format='{0.day:02d}.{0.month:02d}.{0.year:4d}'
if not datetime_:
return ''
try:
if fromIso:
DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
else:
DATETIME_FORMAT = '%Y-%m-%d'
dt = datetime.datetime.strptime(
datetime_, DATETIME_FORMAT)
return dt.strftime('%d.%m.%Y')
......
No preview for this file type
......@@ -291,7 +291,7 @@ msgid "map"
msgstr "Karte"
msgid "wrong_start_date_for_search"
msgstr "Das Datum ist ungültig"
msgstr "Das Startdatum ist ungültig"
msgid "wrong_end_date_for_search"
msgstr "Das Datum ist ungültig"
msgstr "Das Enddatum ist ungültig"
......@@ -367,6 +367,9 @@ label.rangesearch.disabled {
top: -8px;
right: -8px;
}
.pill.error .remove .fa.fa-times{
background-color: #d4004b;
}
.container-fluid.odsh-dataset-item {
padding: 20px 0px 20px 0px;
......@@ -1349,6 +1352,10 @@ display: none;
background-color: #003064;
color:white;
}
.filtered.pill.error{
background-color: #d4004b;
}
.site-title{
color:black;
/* text-align:center; */
......
......@@ -39,9 +39,9 @@ default_extent="{ \"type\": \"Polygon\", \"coordinates\": [[[7.6574,53.1632],[11
<form id="date-search-form" method="get" action="{% url_for controller='package', action='search' %}">
<div class='controls rangesearch'>
{%- set start = request.params['ext_startdate'] -%}
{%- set start_error = h.odsh_render_datetime(start) == '' and start -%}
{%- set start_error = h.odsh_render_datetime(start, False) == '' and start -%}
{%- set end = request.params['ext_enddate'] -%}
{%- set end_error = h.odsh_render_datetime(end) == '' and end -%}
{%- set end_error = h.odsh_render_datetime(end, False) == '' and end -%}
{%- set typeStart = 'text' if (start_error or not start) else 'date' -%}
{%- set typeEnd = 'text' if (end_error or not end) else 'date' -%}
{%- set onFocus = 'onfocus=(this.type=\'date\')' -%}
......
......@@ -73,25 +73,37 @@
{% endif %}
{% endif %}
<div id="datesearch-filter">
{%set start_date=h.odsh_render_datetime(request.params.get('ext_startdate'))%}
{%set end_date=h.odsh_render_datetime(request.params.get('ext_enddate'))%}
{%set start_date=h.odsh_render_datetime(request.params.get('ext_startdate'), False)%}
{%set end_date=h.odsh_render_datetime(request.params.get('ext_enddate'), False)%}
{%- set start_error = start_date == '' and request.params.get('ext_startdate')-%}
{%- set end_error = end_date == '' and request.params.get('ext_enddate')-%}
{% if (start_date or end_date) and (not start_error and not end_error)%}
{% if start_date or end_date or start_error or end_error%}
<p class="filter-list">
{% if start_date %}
{% if start_date and not start_error%}
<span class="filtered pill">
{{_('daterange')}}: {{_('from')}} {{ start_date}}
<a href="{{ h.remove_url_param('ext_startdate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a>
</span>
{% endif %}
{% if start_error %}
<span class="filtered pill error">
{{_('daterange')}}: {{_('wrong_start_date_for_search')}}
<a href="{{ h.remove_url_param('ext_startdate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a>
</span>
{% endif %}
{% if end_date %}
{% if end_date and not end_error%}
<span class="filtered pill">
{{_('daterange')}}: {{_('to')}} {{ end_date}}
<a href="{{ h.remove_url_param('ext_enddate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a>
</span>
{% endif %}
{% if end_error %}
<span class="filtered pill error">
{{_('daterange')}}: {{_('wrong_end_date_for_search')}}
<a href="{{ h.remove_url_param('ext_enddate') }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a>
</span>
{% endif %}
</p>
{% endif %}
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment