From 04f6ed61bc1d0b4483fadaa446707d6e164f121e Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Wed, 22 Jan 2025 17:53:00 +0100 Subject: [PATCH] =?UTF-8?q?refactor(graphs):=20=F0=9F=8E=A8=20replace=20mo?= =?UTF-8?q?del=20field=20choices=20filter=20with=20list=20comprehension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scipost_django/graphs/forms.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scipost_django/graphs/forms.py b/scipost_django/graphs/forms.py index e49a69eaf..e17f40eff 100644 --- a/scipost_django/graphs/forms.py +++ b/scipost_django/graphs/forms.py @@ -103,12 +103,13 @@ class PlotOptionsForm(forms.Form): # Update the allowed kind choices based on the selected model field plotter if plotter := self.model_field_select_form.plotter: - self.plot_kind_select_form.fields["plot_kind"].choices = list( - filter( - lambda x: x[0] in plotter.get_available_plot_kinds(), - self.plot_kind_select_form.fields["plot_kind"].choices, - ) - ) + plot_kind_select = self.plot_kind_select_form.fields["plot_kind"] + plot_kind_choices = [ + (key, display_str) + for key, display_str in plot_kind_select.choices + if key in plotter.get_available_plot_kinds() or key is None + ] + plot_kind_select.choices = plot_kind_choices super().__init__(*args, **kwargs) self.helper = FormHelper() -- GitLab