Skip to content

Commit

Permalink
Move contract date to contract attach and add contract renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
uck9 committed Oct 13, 2024
1 parent 751606e commit 75c9efc
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 12 deletions.
7 changes: 4 additions & 3 deletions netbox_lifecycle/api/_serializers/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ class HardwareLifecycleSerializer(NetBoxModelSerializer):
end_of_sale = serializers.DateField()
end_of_maintenance = serializers.DateField(required=False)
end_of_security = serializers.DateField(required=False)
last_contract_date = serializers.DateField(required=False)
last_contract_attach = serializers.DateField(required=False)
last_contract_renewal = serializers.DateField(required=False)
end_of_support = serializers.DateField()

class Meta:
model = HardwareLifecycle
fields = (
'url', 'id', 'display', 'assigned_object_type', 'assigned_object_id', 'end_of_sale',
'end_of_maintenance', 'end_of_security', 'last_contract_date', 'end_of_support', 'notice', 'documentation',
'description', 'comments',
'end_of_maintenance', 'end_of_security', 'last_contract_attach', 'last_contract_renewal',
'end_of_support', 'notice', 'documentation', 'description', 'comments',
)
brief_fields = (
'url', 'id', 'display', 'assigned_object_type', 'assigned_object_id', 'end_of_sale',
Expand Down
5 changes: 3 additions & 2 deletions netbox_lifecycle/forms/model_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,12 @@ class HardwareLifecycleForm(NetBoxModelForm):
class Meta:
model = HardwareLifecycle
fields = (
'last_contract_date', 'end_of_sale', 'end_of_maintenance', 'end_of_security', 'end_of_support', 'notice',
'last_contract_attach', 'last_contract_renewal', 'end_of_sale', 'end_of_maintenance', 'end_of_security', 'end_of_support', 'notice',
'documentation', 'description', 'comments', 'tags',
)
widgets = {
'last_contract_date': DatePicker(),
'last_contract_attach': DatePicker(),
'last_contract_renewal': DatePicker(),
'end_of_sale': DatePicker(),
'end_of_maintenance': DatePicker(),
'end_of_security': DatePicker(),
Expand Down
3 changes: 2 additions & 1 deletion netbox_lifecycle/graphql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class HardwareLifecycleType(NetBoxObjectType):
end_of_sale: str
end_of_maintenance: str | None
end_of_security: str | None
last_contract_date: str | None
last_contract_attach: str | None
last_contract_renewal: str | None
end_of_support: str
notice: str | None
documentation: str | None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.9 on 2024-10-13 03:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('netbox_lifecycle', '0013_fix_hardware_lifecycle_model'),
]

operations = [
migrations.RenameField(
model_name='hardwarelifecycle',
old_name='last_contract_date',
new_name='last_contract_attach',
),
migrations.AddField(
model_name='hardwarelifecycle',
name='last_contract_renewal',
field=models.DateField(blank=True, null=True),
),
]
3 changes: 2 additions & 1 deletion netbox_lifecycle/models/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class HardwareLifecycle(PrimaryModel):
end_of_sale = models.DateField()
end_of_maintenance = models.DateField(blank=True, null=True)
end_of_security = models.DateField(blank=True, null=True)
last_contract_date = models.DateField(blank=True, null=True)
last_contract_attach = models.DateField(blank=True, null=True)
last_contract_renewal = models.DateField(blank=True, null=True)
end_of_support = models.DateField()

notice = models.CharField(max_length=500, blank=True, null=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ <h5 class="card-header">Dates</h5>
<td><span {{ object.end_of_security|date_badge_class }}>{{ object.end_of_security }}</span></td>
</tr>
<tr>
<td>Last Support Contract Purchase Date</td>
<td><span {{ object.last_contract_date|date_badge_class }}>{{ object.last_contract_date }}</span></td>
<td>Last Support Contract Attach</td>
<td><span {{ object.last_contract_attach|date_badge_class }}>{{ object.last_contract_attach }}</span></td>
</tr>
<tr>
<td>Last Support Contract Renewal</td>
<td><span {{ object.last_contract_renewal|date_badge_class }}>{{ object.last_contract_renewal }}</span></td>
</tr>
<tr>
<td>End of Support</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ <h5 class="offset-sm-3">Key Dates</h5>
{% render_field form.end_of_sale %}
{% render_field form.end_of_maintenance %}
{% render_field form.end_of_security %}
{% render_field form.last_contract_date %}
{% render_field form.last_contract_attach %}
{% render_field form.last_contract_renewal %}
{% render_field form.end_of_support %}
</div>
<div class="field-group my-5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ <h5 class="card-header">Lifecycle Dates</h5>
<td><span {{ lifecycle_info.end_of_security|date_badge_class }}>{{ lifecycle_info.end_of_security }}</span></td>
</tr>
<tr>
<td>Last Support Contract Purchase Date</td>
<td><span {{ lifecycle_info.last_contract_date|date_badge_class }}>{{ lifecycle_info.last_contract_date }}</span></td>
<td>Last Support Contract Attach</td>
<td><span {{ lifecycle_info.last_contract_attach|date_badge_class }}>{{ lifecycle_info.last_contract_attach }}</span></td>
</tr>
<tr>
<td>Last Support Contract Renewal</td>
<td><span {{ lifecycle_info.last_contract_renewal|date_badge_class }}>{{ lifecycle_info.last_contract_renewal }}</span></td>
</tr>
<tr>
<td>End of Support</td>
Expand Down

0 comments on commit 75c9efc

Please sign in to comment.