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