Skip to content

Commit

Permalink
fix: modifify facility_system model
Browse files Browse the repository at this point in the history
  • Loading branch information
saladgg committed Sep 14, 2021
1 parent 05fec7d commit 9e63c5d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fahari/ops/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FacilitySystemFilter(CommonFieldsFilterset):
class Meta:

model = FacilitySystem
fields = "__all__"
exclude = ("attachment",)


class FacilitySystemTicketFilter(CommonFieldsFilterset):
Expand Down
29 changes: 29 additions & 0 deletions fahari/ops/migrations/0026_auto_20210914_1059.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.7 on 2021-09-14 07:59

from django.db import migrations, models
import fahari.common.models


class Migration(migrations.Migration):

dependencies = [
('ops', '0025_securityincidence'),
]

operations = [
migrations.AddField(
model_name='facilitysystem',
name='attachment',
field=models.FileField(blank=True, null=True, upload_to=fahari.common.models.get_directory, verbose_name='Attach File or Photo'),
),
migrations.AddField(
model_name='facilitysystem',
name='release_notes',
field=models.TextField(default='-'),
),
migrations.AddField(
model_name='facilitysystem',
name='trainees',
field=models.TextField(default='-'),
),
]
5 changes: 5 additions & 0 deletions fahari/ops/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ class FacilitySystem(AbstractBase):
facility = models.ForeignKey(Facility, on_delete=models.PROTECT)
system = models.ForeignKey(System, on_delete=models.PROTECT)
version = models.CharField(max_length=64)
release_notes = models.TextField(default="-")
trainees = models.TextField(default="-")
attachment = models.FileField(
upload_to=get_directory, verbose_name="Attach File or Photo", null=True, blank=True
)

def get_absolute_url(self):
update_url = reverse_lazy("ops:version_update", kwargs={"pk": self.pk})
Expand Down
1 change: 1 addition & 0 deletions fahari/ops/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FacilitySystemSerializer(BaseSerializer):

facility_name = serializers.ReadOnlyField()
system_name = serializers.ReadOnlyField()
updated = serializers.DateTimeField(format="%d/%m/%Y", required=False)

class Meta(BaseSerializer.Meta):
model = FacilitySystem
Expand Down
13 changes: 11 additions & 2 deletions fahari/ops/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def test_create(self):
"system": self.system.pk,
"version": fake.name()[:63],
"organisation": self.global_organisation.pk,
"release_notes": fake.text(),
"trainees": fake.text(),
"attachment": fake.file_name(),
}
response = self.client.post(reverse("ops:version_create"), data=data)
self.assertEqual(
Expand All @@ -138,9 +141,12 @@ def test_update(self):
data = {
"pk": instance.pk,
"facility": self.facility.pk,
"organisation": self.global_organisation.pk,
"system": self.system.pk,
"version": fake.name()[:63],
"organisation": self.global_organisation.pk,
"release_notes": fake.text(),
"trainees": fake.text(),
"attachment": fake.file_name(),
}
response = self.client.post(
reverse("ops:version_update", kwargs={"pk": instance.pk}), data=data
Expand Down Expand Up @@ -260,10 +266,13 @@ def setUp(self):
def test_create(self):
data = {
"facility_system": self.facility_system.pk,
"organisation": self.global_organisation.pk,
"details": fake.text(),
"raised": timezone.now().isoformat(),
"raised_by": fake.name(),
"organisation": self.global_organisation.pk,
"resolved": timezone.now().isoformat(),
"resolved_by": fake.name(),
"resolved_note": fake.text(),
}
response = self.client.post(reverse("ops:ticket_create"), data=data)
self.assertEqual(
Expand Down
2 changes: 2 additions & 0 deletions fahari/templates/pages/ops/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h1 class="h3 mb-4 text-gray-800">
<th>Facility</th>
<th>System</th>
<th>Version</th>
<th>Last Updated</th>
<th></th>
</tr>
</thead>
Expand All @@ -56,6 +57,7 @@ <h1 class="h3 mb-4 text-gray-800">
{data: "facility_name", name: "facility__name"},
{data: "system_name", name: "system__name"},
{data: "version", name: "version"},
{data: "updated", name: "updated"},
{
data: "url",
name: "id",
Expand Down

0 comments on commit 9e63c5d

Please sign in to comment.