Skip to content

Commit

Permalink
Change apply to add
Browse files Browse the repository at this point in the history
  • Loading branch information
grigorescu committed Jan 5, 2024
1 parent 9143353 commit 46dafa8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions scram/route_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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",
}
Expand Down

0 comments on commit 46dafa8

Please sign in to comment.