From 125f88f9e86e2fc2b485b03c309a54d97e1a19a1 Mon Sep 17 00:00:00 2001 From: David Cates Date: Wed, 31 Jul 2024 13:58:40 -0600 Subject: [PATCH] update docstrings, black --- .../contract_filters.py | 4 +--- nautobot_device_lifecycle_mgmt/forms.py | 5 +++-- nautobot_device_lifecycle_mgmt/models.py | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/nautobot_device_lifecycle_mgmt/contract_filters.py b/nautobot_device_lifecycle_mgmt/contract_filters.py index 23bd685e..67583551 100644 --- a/nautobot_device_lifecycle_mgmt/contract_filters.py +++ b/nautobot_device_lifecycle_mgmt/contract_filters.py @@ -28,8 +28,6 @@ def __init__(self, qs, item_obj): # pylint: disable=invalid-name def filter_qs(self): """Returns filtered InventoryItemContractFilter query set.""" - self.contract_qs = self.contract_qs.filter( - Q(inventory_items=self.item_obj.pk) - ).distinct() + self.contract_qs = self.contract_qs.filter(Q(inventory_items=self.item_obj.pk)).distinct() return self.contract_qs diff --git a/nautobot_device_lifecycle_mgmt/forms.py b/nautobot_device_lifecycle_mgmt/forms.py index 04d7adfd..c321d16c 100644 --- a/nautobot_device_lifecycle_mgmt/forms.py +++ b/nautobot_device_lifecycle_mgmt/forms.py @@ -147,8 +147,9 @@ class HardwareLCMFilterForm(NautobotFilterForm): widget=StaticSelect2Multiple(), ) inventory_item = forms.ModelMultipleChoiceField( - queryset=HardwareLCM.objects.filter(inventory_item__isnull=False, device_type__isnull=True) - .values_list("inventory_item", flat=True), + queryset=HardwareLCM.objects.filter(inventory_item__isnull=False, device_type__isnull=True).values_list( + "inventory_item", flat=True + ), to_field_name="inventory_item", label="Inventory Part ID", required=False, diff --git a/nautobot_device_lifecycle_mgmt/models.py b/nautobot_device_lifecycle_mgmt/models.py index 721d3321..7c6d31f6 100644 --- a/nautobot_device_lifecycle_mgmt/models.py +++ b/nautobot_device_lifecycle_mgmt/models.py @@ -400,14 +400,29 @@ def __str__(self): @property def expired(self): - """Return True or False if chosen field is expired.""" + """ + Return 'True' if a contract has expired, return 'False' if it is active. + + If a contract does not have an end date it cannot expire. If the + current date is greater than the end date of a contract, it is + expired. The last day of a contract is still considered to be + in the 'active' period. + """ if not self.end: return False return datetime.today().date() > self.end @property def active(self): - """Return True or False if chosen field is active.""" + """ + Return 'True' if a contract is active, return 'False' if it has expired. + + An active contract is a contract that has not yet expired. + If a contract does not have an end date it cannot expire. If the + current date is less than or equal to the end date of a contract, + it is active. The last day of a contract is still considered to be + in the 'active' period. + """ if not self.end: return True return datetime.today().date() <= self.end