Skip to content
Snippets Groups Projects
Commit 6ecf0eb1 authored by Jan Mach's avatar Jan Mach
Browse files

Added default 'detect time from' time boundary in case there are no time intervals defined.

* If none of the following search parameters (dt_from, dt_to, st_from, st_to) is present in the URL, provide default dt_from (last 7 days) to reduce amount of processed events.
* User still has the ability to perform unbound search by submitting empty form.

(Redmine issue: #4609)
parent e4778560
No related branches found
No related tags found
No related merge requests found
...@@ -51,7 +51,7 @@ BLUEPRINT_NAME = 'events' ...@@ -51,7 +51,7 @@ BLUEPRINT_NAME = 'events'
def _get_search_form(request_args = None): def _get_search_form(request_args = None):
choices = hawat.events.get_event_form_choices() choices = hawat.events.get_event_form_choices()
return SimpleEventSearchForm( form = SimpleEventSearchForm(
request_args, request_args,
meta = {'csrf': False}, meta = {'csrf': False},
choices_source_types = choices['source_types'], choices_source_types = choices['source_types'],
...@@ -66,6 +66,12 @@ def _get_search_form(request_args = None): ...@@ -66,6 +66,12 @@ def _get_search_form(request_args = None):
choices_inspection_errs = choices['inspection_errs'], choices_inspection_errs = choices['inspection_errs'],
) )
# In case no time bounds were set adjust them manually.
if request_args and not ('dt_from' in request_args or 'dt_to' in request_args or 'st_from' in request_args or 'st_to' in request_args):
form.dt_from.process_data(hawat.forms.default_dt_with_delta())
return form
class AbstractSearchView(PsycopgMixin, BaseSearchView): # pylint: disable=locally-disabled,abstract-method class AbstractSearchView(PsycopgMixin, BaseSearchView): # pylint: disable=locally-disabled,abstract-method
""" """
......
...@@ -50,7 +50,7 @@ BLUEPRINT_NAME = 'timeline' ...@@ -50,7 +50,7 @@ BLUEPRINT_NAME = 'timeline'
def _get_search_form(request_args = None): def _get_search_form(request_args = None):
choices = hawat.events.get_event_form_choices() choices = hawat.events.get_event_form_choices()
return SimpleTimelineSearchForm( form = SimpleTimelineSearchForm(
request_args, request_args,
meta = {'csrf': False}, meta = {'csrf': False},
choices_source_types = choices['source_types'], choices_source_types = choices['source_types'],
...@@ -65,6 +65,12 @@ def _get_search_form(request_args = None): ...@@ -65,6 +65,12 @@ def _get_search_form(request_args = None):
choices_inspection_errs = choices['inspection_errs'], choices_inspection_errs = choices['inspection_errs'],
) )
# In case no time bounds were set adjust them manually.
if request_args and not ('dt_from' in request_args or 'dt_to' in request_args or 'st_from' in request_args or 'st_to' in request_args):
form.dt_from.process_data(hawat.forms.default_dt_with_delta())
return form
class AbstractSearchView(PsycopgMixin, BaseSearchView): # pylint: disable=locally-disabled,abstract-method class AbstractSearchView(PsycopgMixin, BaseSearchView): # pylint: disable=locally-disabled,abstract-method
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment