From 2b3f599ef83e28d7957a8316ac5bef9c8e24abe6 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Fri, 24 Jan 2025 11:45:14 +0100 Subject: [PATCH] =?UTF-8?q?refactor(graphs):=20=E2=99=BB=EF=B8=8F=20rename?= =?UTF-8?q?=20x=20lim=20keys=20to=20timeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scipost_django/graphs/graphs/plotkind.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scipost_django/graphs/graphs/plotkind.py b/scipost_django/graphs/graphs/plotkind.py index 5af6fe655..45033a613 100644 --- a/scipost_django/graphs/graphs/plotkind.py +++ b/scipost_django/graphs/graphs/plotkind.py @@ -127,10 +127,10 @@ class TimelinePlot(PlotKind): } ) # Filter the queryset according to the date limits if they are set - if x_lim_min := self.options.get("x_lim_min", None): - query_filters &= Q(**{timeline_key + "__gte": x_lim_min}) - if x_lim_max := self.options.get("x_lim_max", None): - query_filters &= Q(**{timeline_key + "__lte": x_lim_max}) + if timeline_min := self.options.get("timeline_min", None): + query_filters &= Q(**{timeline_key + "__gte": timeline_min}) + if timeline_max := self.options.get("timeline_max", None): + query_filters &= Q(**{timeline_key + "__lte": timeline_max}) qs = self.plotter.get_queryset() qs = qs.filter(query_filters) @@ -148,13 +148,13 @@ class TimelinePlot(PlotKind): value_key = forms.ChoiceField( label="Value key", initial="id", required=False, choices=[] ) - x_lim_min = forms.DateTimeField( - label="X min", + timeline_min = forms.DateTimeField( + label="After", required=False, widget=forms.DateTimeInput(attrs={"type": "date"}), ) - x_lim_max = forms.DateTimeField( - label="X max", + timeline_max = forms.DateTimeField( + label="Before", required=False, widget=forms.DateTimeInput(attrs={"type": "date"}), ) @@ -163,8 +163,8 @@ class TimelinePlot(PlotKind): def get_plot_options_form_layout_row_content(cls): return Layout( Div(Field("timeline_key"), css_class="col-12"), - Div(Field("x_lim_min"), css_class="col-6"), - Div(Field("x_lim_max"), css_class="col-6"), + Div(Field("timeline_min"), css_class="col-6"), + Div(Field("timeline_max"), css_class="col-6"), Div(Field("value_key"), css_class="col-12"), ) -- GitLab