Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ca 545 add ref id to all editable objects #1044

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7039444
begin to add ref_id to some data
melinoix Nov 12, 2024
11d6649
working ref_id on project
melinoix Nov 13, 2024
776fe91
added ref_id to assessments and applied_control
melinoix Nov 13, 2024
afa366b
added domain ref id
melinoix Nov 13, 2024
e319556
corrected tradution with paraglide
melinoix Nov 13, 2024
83121ca
corrected migration
melinoix Nov 13, 2024
51916dc
ruff format
melinoix Nov 13, 2024
82e1dfd
corrected migrations & little changes
melinoix Nov 14, 2024
3ddb498
adjust stable version
melinoix Nov 14, 2024
e5b70e9
corrected migrations, added folder, removed internal ref
melinoix Nov 18, 2024
42c0f4d
corrected project api tests
melinoix Nov 18, 2024
2e9be80
Merge branch 'main' into CA-545-add-ref-id-to-all-editable-objects
melinoix Nov 18, 2024
11df68d
merged with main
melinoix Nov 18, 2024
d8c6858
corrected migrations
melinoix Nov 18, 2024
2740b09
corrected migrations
melinoix Nov 18, 2024
e07af5f
correct migrations
melinoix Nov 18, 2024
13af317
correct migrations
melinoix Nov 19, 2024
460c528
correct format
melinoix Nov 19, 2024
2165dab
without folder
melinoix Nov 19, 2024
26bb9fd
Merge branch 'main' into CA-545-add-ref-id-to-all-editable-objects
melinoix Nov 22, 2024
6e3629f
correct migration conflicts
melinoix Nov 22, 2024
2f2ff47
Merge branch 'main' into CA-545-add-ref-id-to-all-editable-objects
nas-tabchiche Nov 23, 2024
2fdab93
Change project internal reference to ref id in tests and interfaces
nas-tabchiche Nov 23, 2024
de46e46
Remove internal_reference from ProjectViewSet.search_fields
nas-tabchiche Nov 23, 2024
f28a936
Change project internal reference to ref id in data model docs
nas-tabchiche Nov 23, 2024
2e9da47
Fix ref id field title functional test
nas-tabchiche Nov 23, 2024
edd2c9b
Change test value for project's ref id
nas-tabchiche Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "0038_asset_disaster_recovery_objectives_and_more"),
]

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 @@ -2394,6 +2401,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 @@ -185,7 +185,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 @@ -1382,6 +1382,7 @@ class FolderViewSet(BaseModelViewSet):

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

def perform_create(self, serializer):
"""
Expand Down Expand Up @@ -1812,7 +1813,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
Loading