Skip to content

Commit

Permalink
ruff + pur
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem committed Apr 28, 2024
1 parent b3fa814 commit 9bc4cba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@
WELL_KNOWN_SCORES = {
"urn:intuitem:risk:framework:tisax-v6.0.2": (0, 5),
"urn:intuitem:risk:framework:ccb-cff-2023-03-01": (1, 5),
"urn:intuitem:risk:framework:nist-csf-2.0": (1,4),
"urn:intuitem:risk:framework:nist-csf-2.0": (1, 4),
}


def fix_well_known_scores(apps, schema_editor):
Framework = apps.get_model('core', 'Framework')
ComplianceAssessment = apps.get_model('core', 'ComplianceAssessment')
Framework = apps.get_model("core", "Framework")
ComplianceAssessment = apps.get_model("core", "ComplianceAssessment")
for framework in Framework.objects.all():
if framework.urn in WELL_KNOWN_SCORES:
(framework.min_score, framework.max_score) = WELL_KNOWN_SCORES[framework.urn]
(framework.min_score, framework.max_score) = WELL_KNOWN_SCORES[
framework.urn
]
framework.save()
print("custom migration for", framework.urn)
for assessment in ComplianceAssessment.objects.all():
if assessment.framework.urn in WELL_KNOWN_SCORES:
(assessment.min_score, assessment.max_score) = WELL_KNOWN_SCORES[assessment.framework.urn]
(assessment.min_score, assessment.max_score) = WELL_KNOWN_SCORES[
assessment.framework.urn
]
assessment.save()
print("custom migration for", assessment.framework.urn)


class Migration(migrations.Migration):
dependencies = [
("core", "0009_framework_max_score_framework_min_score_and_more"),
Expand Down
1 change: 0 additions & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,6 @@ def save(self, *args, **kwargs) -> None:
self.scores_definition = self.framework.scores_definition
super().save(*args, **kwargs)


def get_global_score(self):
requirement_assessments_scored = (
RequirementAssessment.objects.filter(compliance_assessment=self)
Expand Down
6 changes: 3 additions & 3 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pytest-html==4.1.1
django-filter==24.2
whitenoise==6.6.0
argon2-cffi==23.1.0
typing-extensions==4.10.0
djangorestframework==3.15.0
typing-extensions==4.11.0
djangorestframework==3.15.1
django-stubs==4.2.7
coverage==7.4.4
coverage==7.5.0
django-tailwind==3.8.0
pyyaml==6.0.1
django-structlog==8.0.0
Expand Down

0 comments on commit 9bc4cba

Please sign in to comment.