Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions backend/ciso_assistant/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def set_ciso_assistant_url(_, __, event_dict):
"privacy",
"resilience",
"crq",
"metrology",
"core",
"cal",
"django_filters",
Expand Down
28 changes: 28 additions & 0 deletions backend/core/migrations/0118_alter_terminology_field_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.2.7 on 2025-11-30 19:15

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0117_evidencerevision_task_node_tasktemplate_evidences"),
]

operations = [
migrations.AlterField(
model_name="terminology",
name="field_path",
field=models.CharField(
choices=[
("ro_to.risk_origin", "ro_to/risk_origin"),
("qualifications", "qualifications"),
("accreditation.status", "accreditationStatus"),
("accreditation.category", "accreditationCategory"),
("entity.relationship", "entityRelationship"),
("metric_definition.unit", "metricUnit"),
],
max_length=100,
verbose_name="Field path",
),
),
]
49 changes: 49 additions & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ class FieldPath(models.TextChoices):
ACCREDITATION_STATUS = "accreditation.status", "accreditationStatus"
ACCREDITATION_CATEGORY = "accreditation.category", "accreditationCategory"
ENTITY_RELATIONSHIP = "entity.relationship", "entityRelationship"
METRIC_UNIT = "metric_definition.unit", "metricUnit"

DEFAULT_ROTO_RISK_ORIGINS = [
{
Expand Down Expand Up @@ -1279,6 +1280,45 @@ class FieldPath(models.TextChoices):
"is_visible": True,
},
]

DEFAULT_METRIC_UNITS = [
{
"name": "count",
"builtin": True,
"field_path": FieldPath.METRIC_UNIT,
"is_visible": True,
},
{
"name": "users",
"builtin": True,
"field_path": FieldPath.METRIC_UNIT,
"is_visible": True,
},
{
"name": "bytes",
"builtin": True,
"field_path": FieldPath.METRIC_UNIT,
"is_visible": True,
},
{
"name": "percentage",
"builtin": True,
"field_path": FieldPath.METRIC_UNIT,
"is_visible": True,
},
{
"name": "score",
"builtin": True,
"field_path": FieldPath.METRIC_UNIT,
"is_visible": True,
},
{
"name": "event_per_second",
"builtin": True,
"field_path": FieldPath.METRIC_UNIT,
"is_visible": True,
},
]
is_published = models.BooleanField(_("published"), default=True)
field_path = models.CharField(
max_length=100,
Expand Down Expand Up @@ -1350,6 +1390,15 @@ def create_default_entity_relationships(cls):
defaults=item,
)

@classmethod
def create_default_metric_units(cls):
for item in cls.DEFAULT_METRIC_UNITS:
Terminology.objects.update_or_create(
name=item["name"],
field_path=item["field_path"],
defaults=item,
)

@property
def get_name_translated(self) -> str:
translations = self.translations if self.translations else {}
Expand Down
22 changes: 22 additions & 0 deletions backend/core/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,23 @@
"add_accreditation",
"change_accreditation",
"delete_accreditation",
# metrology
"view_metricdefinition",
"add_metricdefinition",
"change_metricdefinition",
"delete_metricdefinition",
"view_metricinstance",
"add_metricinstance",
"change_metricinstance",
"delete_metricinstance",
"view_metricsample",
"add_metricsample",
"change_metricsample",
"delete_metricsample",
"view_dashboard",
"add_dashboard",
"change_dashboard",
"delete_dashboard",
# roles,
"add_role",
"view_role",
Expand Down Expand Up @@ -1188,6 +1205,11 @@ def startup(sender: AppConfig, **kwargs):
except Exception as e:
logger.error("Error creating default Entity Relationships", exc_info=True)

try:
Terminology.create_default_metric_units()
except Exception as e:
logger.error("Error creating default Metric Units", exc_info=True)

# Init integration providers

try:
Expand Down
1 change: 1 addition & 0 deletions backend/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
path("resilience/", include("resilience.urls")),
path("crq/", include("crq.urls")),
path("pmbok/", include("pmbok.urls")),
path("metrology/", include("metrology.urls")),
path("csrf/", get_csrf_token, name="get_csrf_token"),
path("health/", healthcheck, name="healthcheck"),
path("build/", get_build, name="get_build"),
Expand Down
Empty file added backend/metrology/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions backend/metrology/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class MetrologyConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "metrology"
Loading
Loading