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

Put the is_publised attribute in the AbstractBaseModel class #90

Merged
merged 12 commits into from
Mar 1, 2024
5 changes: 5 additions & 0 deletions backend/app_tests/api/test_api_security_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_get_security_functions(self):
"name": SECURITY_FUNCTION_NAME,
"description": SECURITY_FUNCTION_DESCRIPTION,
"folder": Folder.objects.create(name="test"),
"is_published": True,
},
)

Expand Down Expand Up @@ -62,6 +63,7 @@ def test_update_security_functions(self):
"name": SECURITY_FUNCTION_NAME,
"description": SECURITY_FUNCTION_DESCRIPTION,
"folder": Folder.objects.create(name="test"),
"is_published": True,
},
{
"ref_id": "new " + SECURITY_FUNCTION_REF_ID,
Expand All @@ -81,6 +83,7 @@ def test_delete_security_functions(self):
"ref_id": SECURITY_FUNCTION_REF_ID,
"name": SECURITY_FUNCTION_NAME,
"folder": Folder.objects.create(name="test"),
"is_published": True,
},
)

Expand Down Expand Up @@ -108,6 +111,7 @@ def test_get_security_functions(self, test):
"description": SECURITY_FUNCTION_DESCRIPTION,
"urn": SECURITY_FUNCTION_URN,
"provider": SECURITY_FUNCTION_PROVIDER,
"is_published": True,
},
{
"folder": {"str": Folder.get_root_folder().name},
Expand Down Expand Up @@ -148,6 +152,7 @@ def test_update_security_function_with_urn(self, test):
"description": SECURITY_FUNCTION_DESCRIPTION,
"urn": SECURITY_FUNCTION_URN,
"provider": SECURITY_FUNCTION_PROVIDER,
"is_published": True,
},
{
"ref_id": SECURITY_FUNCTION_REF_ID,
Expand Down
4 changes: 4 additions & 0 deletions backend/app_tests/api/test_api_threats.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_get_threats(self):
"ref_id": THREAT_REF_ID,
"name": THREAT_NAME,
"description": THREAT_DESCRIPTION,
"is_published": True,
"folder": Folder.objects.create(name="test"),
},
)
Expand Down Expand Up @@ -64,6 +65,7 @@ def test_update_threats(self):
"description": THREAT_DESCRIPTION,
"provider": THREAT_PROVIDER,
"folder": Folder.objects.create(name="test"),
"is_published": True,
},
{
"ref_id": "new " + THREAT_REF_ID,
Expand Down Expand Up @@ -111,6 +113,7 @@ def test_get_threats(self, test):
"description": THREAT_DESCRIPTION,
"provider": THREAT_PROVIDER,
"urn": THREAT_URN,
"is_published": True,
},
{
"folder": {"str": Folder.get_root_folder().name},
Expand Down Expand Up @@ -153,6 +156,7 @@ def test_update_threats_with_urn(self, test):
"description": THREAT_DESCRIPTION,
"provider": THREAT_PROVIDER,
"urn": THREAT_URN,
"is_published": True,
},
{
"ref_id": "new " + THREAT_REF_ID,
Expand Down
26 changes: 10 additions & 16 deletions backend/cal/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
# Generated by Django 5.0.2 on 2024-02-25 00:59
# Generated by Django 5.0.2 on 2024-02-29 14:47

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []
dependencies = [
]

operations = [
migrations.CreateModel(
name="Event",
name='Event',
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=200)),
("description", models.TextField()),
("start_time", models.DateTimeField()),
("end_time", models.DateTimeField()),
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('description', models.TextField()),
('start_time', models.DateTimeField()),
('end_time', models.DateTimeField()),
],
),
]
1 change: 1 addition & 0 deletions backend/core/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class AbstractBaseModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created_at = models.DateTimeField(auto_now_add=True, verbose_name=_("Created at"))
updated_at = models.DateTimeField(auto_now=True, verbose_name=_("UpdatedÒ at"))
is_published = models.BooleanField(_("published"), default=False)

class Meta:
abstract = True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Generated by Django 5.0.2 on 2024-02-29 20:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0003_alter_riskscenario_strength_of_knowledge'),
]

operations = [
migrations.AddField(
model_name='complianceassessment',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='evidence',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='framework',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='library',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='project',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='requirementassessment',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='requirementlevel',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='requirementnode',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='riskacceptance',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='riskassessment',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='riskmatrix',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='riskscenario',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AddField(
model_name='securitymeasure',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AlterField(
model_name='asset',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AlterField(
model_name='securityfunction',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
migrations.AlterField(
model_name='threat',
name='is_published',
field=models.BooleanField(default=False, verbose_name='published'),
),
]
3 changes: 0 additions & 3 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class Threat(ReferentialObjectMixin):
library = models.ForeignKey(
Library, on_delete=models.CASCADE, null=True, blank=True, related_name="threats"
)
is_published = models.BooleanField(_("published"), default=True)

class Meta:
verbose_name = _("Threat")
Expand Down Expand Up @@ -189,7 +188,6 @@ class SecurityFunction(ReferentialObjectMixin):
typical_evidence = models.JSONField(
verbose_name=_("Typical evidence"), null=True, blank=True
)
is_published = models.BooleanField(_("published"), default=True)

class Meta:
verbose_name = _("Security function")
Expand Down Expand Up @@ -423,7 +421,6 @@ class Type(models.TextChoices):
parent_assets = models.ManyToManyField(
"self", blank=True, verbose_name=_("parent assets"), symmetrical=False
)
is_published = models.BooleanField(_("published"), default=True)

fields_to_check = ["name"]

Expand Down
Loading
Loading