diff --git a/web/run.py b/web/run.py index 6092549..a26e78b 100755 --- a/web/run.py +++ b/web/run.py @@ -1082,26 +1082,32 @@ def get_input_slug_from_query(inp=None): return input_slug -def get_default_sta_sto(sta=None, sto=None): +def get_default_sta_sto(sta_str=None, sto_str=None): - # TODO : maybe get from configuration relative_after = config['defaults']['relative_after'] relative_before = config['defaults']['relative_before'] before = relativedelta(months=relative_before) after = relativedelta(months=relative_after) - if sta is None and sto is None: + if sta_str is None and sto_str is None: today = datetime.datetime.now().replace(hour=0, minute=0, second=0) sta_date = today - before sto_date = today + after - if sta is None and sto is not None: - sto_date = dateparser.isoparse(sto) + elif sta_str is not None and sto_str is None: + sta_date = dateparser.isoparse(sta_str) + sto_date = sta_date + after + + elif sta_str is None and sto_str is not None: + sto_date = dateparser.isoparse(sto_str) sta_date = sto_date - before - if sta is not None and sto is None: - sta_date = dateparser.isoparse(sta) - sto_date = sta_date + after + elif sta_str is not None and sto_str is not None: + sto_date = dateparser.isoparse(sto_str) + sta_date = dateparser.isoparse(sta_str) + + else: + raise Exception("IMPOSSIBLE") return sta_date, sto_date -- libgit2 0.21.2