Skip to content

Commit

Permalink
Closes netbox-community#12828: Add color mapping to ChangeActionChoices
Browse files Browse the repository at this point in the history
  • Loading branch information
ingvaldlorentzen committed Jun 7, 2023
1 parent 4a88d5e commit a678db3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions netbox/extras/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class ChangeActionChoices(ChoiceSet):
ACTION_DELETE = 'delete'

CHOICES = (
(ACTION_CREATE, 'Create'),
(ACTION_UPDATE, 'Update'),
(ACTION_DELETE, 'Delete'),
(ACTION_CREATE, 'Create', 'green'),
(ACTION_UPDATE, 'Update', 'blue'),
(ACTION_DELETE, 'Delete', 'red'),
)
3 changes: 3 additions & 0 deletions netbox/extras/models/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ def apply(self):
instance = self.model.objects.get(pk=self.object_id)
logger.info(f'Deleting {self.model._meta.verbose_name} {instance}')
instance.delete()

def get_action_color(self):
return ChangeActionChoices.colors.get(self.action)

0 comments on commit a678db3

Please sign in to comment.