diff --git a/leasing/admin.py b/leasing/admin.py index 05ddcd17..add17fa2 100644 --- a/leasing/admin.py +++ b/leasing/admin.py @@ -773,9 +773,13 @@ class IntendedUseAdmin(admin.ModelAdmin): list_display = ( "name", "service_unit", + "is_active", ) search_fields = ["name_fi"] - list_filter = ("service_unit",) + list_filter = ( + "is_active", + "service_unit", + ) ordering = ( "name_fi", "service_unit", diff --git a/leasing/filters.py b/leasing/filters.py index 2291c7f1..b94b21c7 100644 --- a/leasing/filters.py +++ b/leasing/filters.py @@ -148,7 +148,7 @@ class IntendedUseFilter(FilterSet): class Meta: model = IntendedUse - fields = ["service_unit"] + fields = ["service_unit", "is_active"] class InvoiceFilter(FilterSet): diff --git a/leasing/models/lease.py b/leasing/models/lease.py index 58498988..d3f7b3f5 100644 --- a/leasing/models/lease.py +++ b/leasing/models/lease.py @@ -129,12 +129,6 @@ def __str__(self): return "{} ({})".format(self.name, self.identifier) -class IntendedUseManager(models.Manager): - def get_queryset(self): - # By default, only return active IntendedUses - return super().get_queryset().filter(is_active=True) - - class IntendedUse(NameModel): """ In Finnish: Käyttötarkoitus @@ -150,7 +144,6 @@ class IntendedUse(NameModel): help_text=_("Is the intended use active?"), verbose_name=_("Is active?"), ) - objects = IntendedUseManager() class Meta(NameModel.Meta): verbose_name = pgettext_lazy("Model name", "Intended use") @@ -805,7 +798,7 @@ def get_tenant_shares_for_period( # noqa C901 TODO (billing_overlap, billing_remainders) = get_range_overlap_and_remainder( tenant_overlap[0], tenant_overlap[1], - *billing_tenantcontact.date_range + *billing_tenantcontact.date_range, ) if not billing_overlap: