Skip to content

Commit

Permalink
Audit logs: Show projects for services
Browse files Browse the repository at this point in the history
Before, when displaying the audit logs for services, there was no information
regarding when a project was added on a service, or modified, or deleted.

That information is useful when tracking things down while debugging, so let's
add it.
  • Loading branch information
vincent-olivert-riera committed Jan 19, 2024
1 parent 63163c2 commit 0dc687f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions promgen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class Service(models.Model):
)

notifiers = GenericRelation(Sender)
project_set = GenericRelation("Project")
rule_set = GenericRelation("Rule")

class Meta:
Expand Down
6 changes: 6 additions & 0 deletions promgen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ def get_queryset(self):
content_type_id=ContentType.objects.get_for_model(models.Rule).id,
object_id__in=obj.rule_set.values_list("id", flat=True),
)
if key == "service":
# Only services may have projects
qset |= Q(
content_type_id=ContentType.objects.get_for_model(models.Project).id,
object_id__in=obj.project_set.values_list("id", flat=True),
)
if key == "project":
# Only projects may have exporters
qset |= Q(
Expand Down

0 comments on commit 0dc687f

Please sign in to comment.