Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mvj 542 intendeduse isactive filter #767

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion leasing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion leasing/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class IntendedUseFilter(FilterSet):

class Meta:
model = IntendedUse
fields = ["service_unit"]
fields = ["service_unit", "is_active"]


class InvoiceFilter(FilterSet):
Expand Down
9 changes: 1 addition & 8 deletions leasing/models/lease.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down