Skip to content

Commit

Permalink
Ca 545 add ref id to all editable objects (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem authored Nov 27, 2024
2 parents 539b51e + 3756838 commit 0dcb101
Show file tree
Hide file tree
Showing 21 changed files with 217 additions and 80 deletions.
8 changes: 4 additions & 4 deletions backend/app_tests/api/test_api_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_get_projects(self, test):
"name": PROJECT_NAME,
"description": PROJECT_DESCRIPTION,
"folder": test.folder,
"internal_reference": PROJECT_REFERENCE,
"ref_id": PROJECT_REFERENCE,
"lc_status": PROJECT_STATUS[0],
},
{
Expand All @@ -112,7 +112,7 @@ def test_create_projects(self, test):
"name": PROJECT_NAME,
"description": PROJECT_DESCRIPTION,
"folder": str(test.folder.id),
"internal_reference": PROJECT_REFERENCE,
"ref_id": PROJECT_REFERENCE,
"lc_status": PROJECT_STATUS[0],
},
{
Expand All @@ -137,14 +137,14 @@ def test_update_projects(self, test):
"name": PROJECT_NAME,
"description": PROJECT_DESCRIPTION,
"folder": test.folder,
"internal_reference": PROJECT_REFERENCE,
"ref_id": PROJECT_REFERENCE,
"lc_status": PROJECT_STATUS[0],
},
{
"name": "new " + PROJECT_NAME,
"description": "new " + PROJECT_DESCRIPTION,
"folder": str(folder.id),
"internal_reference": "new " + PROJECT_REFERENCE,
"ref_id": "new " + PROJECT_REFERENCE,
"lc_status": status[0],
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 5.1.1 on 2024-11-19 10:15

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0040_riskscenario_ref_id"),
]

operations = [
migrations.RenameField(
model_name="project", old_name="internal_reference", new_name="ref_id"
),
migrations.AlterField(
model_name="project",
name="ref_id",
field=models.CharField(
blank=True, max_length=100, null=True, verbose_name="reference id"
),
),
migrations.AddField(
model_name="appliedcontrol",
name="ref_id",
field=models.CharField(
blank=True, max_length=100, null=True, verbose_name="reference id"
),
),
migrations.AddField(
model_name="complianceassessment",
name="ref_id",
field=models.CharField(
blank=True, max_length=100, null=True, verbose_name="reference id"
),
),
migrations.AddField(
model_name="riskassessment",
name="ref_id",
field=models.CharField(
blank=True, max_length=100, null=True, verbose_name="reference id"
),
),
]
14 changes: 12 additions & 2 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,9 @@ class Project(NameDescriptionMixin, FolderMixin):
("eol", _("EndOfLife")),
("dropped", _("Dropped")),
]
internal_reference = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("Internal reference")

ref_id = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("reference id")
)
lc_status = models.CharField(
max_length=20,
Expand Down Expand Up @@ -1541,6 +1542,9 @@ class Status(models.TextChoices):
blank=True,
verbose_name=_("Reference Control"),
)
ref_id = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("reference id")
)
evidences = models.ManyToManyField(
Evidence,
blank=True,
Expand Down Expand Up @@ -1803,6 +1807,9 @@ class RiskAssessment(Assessment):
help_text=_("WARNING! After choosing it, you will not be able to change it"),
verbose_name=_("Risk matrix"),
)
ref_id = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("reference id")
)

class Meta:
verbose_name = _("Risk assessment")
Expand Down Expand Up @@ -2399,6 +2406,9 @@ class ComplianceAssessment(Assessment):
selected_implementation_groups = models.JSONField(
blank=True, null=True, verbose_name=_("Selected implementation groups")
)
ref_id = models.CharField(
max_length=100, null=True, blank=True, verbose_name=_("reference id")
)
# score system is suggested by the framework, but can be changed at the start of the assessment
min_score = models.IntegerField(null=True, verbose_name=_("Minimum score"))
max_score = models.IntegerField(null=True, verbose_name=_("Maximum score"))
Expand Down
5 changes: 3 additions & 2 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ProjectViewSet(BaseModelViewSet):

model = Project
filterset_fields = ["folder", "lc_status"]
search_fields = ["name", "internal_reference", "description"]
search_fields = ["name", "ref_id", "description"]

@action(detail=False, name="Get status choices")
def lc_status(self, request):
Expand Down Expand Up @@ -1418,6 +1418,7 @@ class FolderViewSet(BaseModelViewSet):

model = Folder
filterset_class = FolderFilter
search_fields = ["ref_id"]

def perform_create(self, serializer):
"""
Expand Down Expand Up @@ -1848,7 +1849,7 @@ class ComplianceAssessmentViewSet(BaseModelViewSet):

model = ComplianceAssessment
filterset_fields = ["framework", "project", "status"]
search_fields = ["name", "description"]
search_fields = ["name", "description", "ref_id"]
ordering_fields = ["name", "description"]

@method_decorator(cache_page(60 * LONG_CACHE_TTL))
Expand Down
1 change: 1 addition & 0 deletions backend/iam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ContentType(models.TextChoices):
content_type = models.CharField(
max_length=2, choices=ContentType.choices, default=ContentType.DOMAIN
)

parent_folder = models.ForeignKey(
"self",
null=True,
Expand Down
Loading

0 comments on commit 0dcb101

Please sign in to comment.