From 46dafa863167e44026afd5ac7ef2d8da75927930 Mon Sep 17 00:00:00 2001 From: Vlad Grigorescu Date: Fri, 5 Jan 2024 16:31:13 -0600 Subject: [PATCH] Change apply to add --- scram/route_manager/models.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scram/route_manager/models.py b/scram/route_manager/models.py index 101359ba..c1f07486 100644 --- a/scram/route_manager/models.py +++ b/scram/route_manager/models.py @@ -25,12 +25,8 @@ def __str__(self): class ActionType(models.Model): """Defines an action that can be done with a given route. e.g. Block, shunt, redirect, etc.""" - name = models.CharField( - help_text="One-word description of the action", max_length=30 - ) - available = models.BooleanField( - help_text="Is this a valid choice for new entries?", default=True - ) + name = models.CharField(help_text="One-word description of the action", max_length=30) + available = models.BooleanField(help_text="Is this a valid choice for new entries?", default=True) history = HistoricalRecords() def __str__(self): @@ -43,18 +39,26 @@ class WebSocketMessage(models.Model): """Defines a single message sent to downstream translators via WebSocket.""" msg_type = models.CharField("The type of the message", max_length=50) - msg_data = models.JSONField("The JSON payload. See also msg_data_route_field.") - msg_data_route_field = models.CharField("The key in the JSON payload whose value will contain the route being acted on.") + msg_data = models.JSONField("The JSON payload. See also msg_data_route_field.", default=dict) + msg_data_route_field = models.CharField( + "The key in the JSON payload whose value will contain the route being acted on." + ) + + def __str__(self): + return f"{msg_type}: {msg_data} with the route in key {msg_data_route_field}" class WebSocketSequenceElement(models.Model): """In a sequence of messages, defines a single element.""" websocketmessage = models.ForeignKey("WebSocketMessage", on_delete=models.CASCADE) - order_num = models.SmallIntegerField("Sequences are sent from the smallest order_num to the highest. Messages with the same order_num could be sent in any order", default=0) + order_num = models.SmallIntegerField( + "Sequences are sent from the smallest order_num to the highest. Messages with the same order_num could be sent in any order", + default=0, + ) VERB_CHOICES = { - "A": "Apply", + "A": "Add", "C": "Check", "R": "Remove", }