diff --git a/scipost_django/graphs/forms.py b/scipost_django/graphs/forms.py index 2fccdc33cc34f7de9f77b25b58fd05b8e7ed009e..fa182abafab9b1231f333b88d5a845f479a45f1d 100644 --- a/scipost_django/graphs/forms.py +++ b/scipost_django/graphs/forms.py @@ -147,6 +147,8 @@ class PlotOptionsForm(forms.Form): # Iterate over all forms and construct the form layout # either by extending the layout with the preferred layout from the object class # or by creating a row with all fields that are not already in the layout + form: forms.Form + object_class: ModelFieldPlotter | PlotKind | None for form, object_class in { self.model_field_select_form: self.model_field_select_form.plotter.__class__, self.plot_kind_select_form: self.plot_kind_select_form.kind_class, @@ -172,7 +174,7 @@ class PlotOptionsForm(forms.Form): ) if get_row_field_layout: try: - object_class_prefix = object_class.Options.prefix or "" + object_class_prefix = str(object_class.Options.prefix) or "" except AttributeError: object_class_prefix = "" diff --git a/scipost_django/graphs/graphs/plotter.py b/scipost_django/graphs/graphs/plotter.py index c1daec6604698ea4af77a1ea2a0ee929ddecc091..81322b3d94a3b9a384cb3e47be1b996b09fa6850 100644 --- a/scipost_django/graphs/graphs/plotter.py +++ b/scipost_django/graphs/graphs/plotter.py @@ -53,7 +53,7 @@ class ModelFieldPlotter(ABC): def __str__(self): return self.get_name() - def get_queryset(self): + def get_queryset(self) -> models.QuerySet[Any]: qs = self.model.objects.all() return qs @@ -150,7 +150,7 @@ class FellowshipPlotter(ModelFieldPlotter): date_key = "start_date" country_key = "latest_affiliation_country" - def get_queryset(self): + def get_queryset(self) -> models.QuerySet[Fellowship]: qs = super().get_queryset() return qs.annotate( @@ -175,7 +175,7 @@ class RefereePlotter(ModelFieldPlotter): date_key = "latest_report_date" country_key = "referee_country" - def get_queryset(self): + def get_queryset(self) -> models.QuerySet[Profile]: qs = super().get_queryset() return qs.annotate( latest_report_date=models.Subquery( @@ -205,7 +205,7 @@ class AuthorPlotter(ModelFieldPlotter): date_key = "first_authorship_date" country_key = "author_country" - def get_queryset(self): + def get_queryset(self) -> models.QuerySet[Profile]: qs = super().get_queryset() return qs.annotate( first_authorship_date=models.Subquery( @@ -235,7 +235,7 @@ class SponsorPlotter(ModelFieldPlotter): date_key = "latest_subsidy" country_key = "country" - def get_queryset(self): + def get_queryset(self) -> models.QuerySet[Organization]: qs = super().get_queryset() return qs.annotate( latest_subsidy=models.Subquery( @@ -251,7 +251,7 @@ class ReportPlotter(ModelFieldPlotter): date_key = "created" country_key = "latest_affiliation_country" - def get_queryset(self): + def get_queryset(self) -> models.QuerySet[Report]: qs = super().get_queryset() return qs.annotate(