Skip to content

Commit

Permalink
update docstrings, black
Browse files Browse the repository at this point in the history
  • Loading branch information
David Cates committed Jul 31, 2024
1 parent 9be4d61 commit 125f88f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 1 addition & 3 deletions nautobot_device_lifecycle_mgmt/contract_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions nautobot_device_lifecycle_mgmt/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 17 additions & 2 deletions nautobot_device_lifecycle_mgmt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 125f88f

Please sign in to comment.