Skip to content

Commit

Permalink
add migration, fix integration config getter
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Jul 27, 2024
1 parent e2a33e9 commit db5d694
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
13 changes: 6 additions & 7 deletions api/audit/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ def call_webhooks(sender, instance, **kwargs):
def _get_integration_config(
instance: AuditLog, integration_name: str
) -> IntegrationsModel | None:
match True:
case hasattr(instance.organisation as organisation, integration_name):
return getattr(organisation, integration_name)
case hasattr(instance.project as project, integration_name):
return getattr(project, integration_name)
case hasattr(instance.environment as environment, integration_name):
return getattr(environment, integration_name)
if hasattr(organisation := instance.organisation, integration_name):
return getattr(organisation, integration_name)

Check warning on line 49 in api/audit/signals.py

View check run for this annotation

Codecov / codecov/patch

api/audit/signals.py#L49

Added line #L49 was not covered by tests
if hasattr(project := instance.project, integration_name):
return getattr(project, integration_name)
if hasattr(environment := instance.environment, integration_name):
return getattr(environment, integration_name)

Check warning on line 53 in api/audit/signals.py

View check run for this annotation

Codecov / codecov/patch

api/audit/signals.py#L53

Added line #L53 was not covered by tests
return None


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 3.2.25 on 2024-07-27 14:21

from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):
dependencies = [
("organisations", "0055_alter_percent_usage"),
("projects", "0024_add_project_edge_v2_migration_read_capacity_budget"),
("grafana", "0001_initial"),
]

operations = [
migrations.RenameModel(
old_name="GrafanaConfiguration",
new_name="GrafanaProjectConfiguration",
),
migrations.CreateModel(
name="GrafanaOrganisationConfiguration",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"deleted_at",
models.DateTimeField(
blank=True,
db_index=True,
default=None,
editable=False,
null=True,
),
),
(
"uuid",
models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
),
("base_url", models.URLField(null=True)),
("api_key", models.CharField(max_length=100)),
(
"organisation",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="grafana_config",
to="organisations.organisation",
),
),
],
options={
"abstract": False,
},
),
]
3 changes: 0 additions & 3 deletions api/integrations/grafana/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class GrafanaProjectConfiguration(IntegrationsModel):
Project, on_delete=models.CASCADE, related_name="grafana_config"
)

class Meta:
db_table = "grafana_configuration"


class GrafanaOrganisationConfiguration(IntegrationsModel):
organisation = models.OneToOneField(
Expand Down

0 comments on commit db5d694

Please sign in to comment.