Skip to content

Commit

Permalink
backoffice: rename foreign key for workflow in ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Aug 28, 2024
1 parent ef63c20 commit 5761f3f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backoffice/backoffice/workflows/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class WorkflowTicketSerializer(serializers.ModelSerializer):
ticket_url = serializers.SerializerMethodField()
workflow_id = serializers.PrimaryKeyRelatedField(queryset=Workflow.objects.all())
workflow = serializers.PrimaryKeyRelatedField(queryset=Workflow.objects.all())

class Meta:
model = WorkflowTicket
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.6 on 2024-08-28 11:55

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("workflows", "0010_alter_decision_workflow_and_more"),
]

operations = [
migrations.RenameField(
model_name="workflowticket",
old_name="workflow_id",
new_name="workflow",
),
]
2 changes: 1 addition & 1 deletion backoffice/backoffice/workflows/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Workflow(models.Model):


class WorkflowTicket(models.Model):
workflow_id = models.ForeignKey(
workflow = models.ForeignKey(
Workflow, related_name="tickets", on_delete=models.CASCADE
)
ticket_id = models.CharField(
Expand Down
10 changes: 5 additions & 5 deletions backoffice/backoffice/workflows/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_list_anonymous(self):

def test_tickets(self):
WorkflowTicket.objects.create(
workflow_id=self.workflow, ticket_id="123", ticket_type="author_create_user"
workflow=self.workflow, ticket_id="123", ticket_type="author_create_user"
)
workflow_data = WorkflowSerializer(self.workflow).data

Expand Down Expand Up @@ -242,7 +242,7 @@ def setUp(self):
data={}, status="running", core=True, is_update=False
)
self.workflow_ticket = WorkflowTicket.objects.create(
workflow_id=self.workflow, ticket_id="123", ticket_type="author_create_user"
workflow=self.workflow, ticket_id="123", ticket_type="author_create_user"
)

def test_get_missing_params(self):
Expand Down Expand Up @@ -294,15 +294,15 @@ def test_create_missing_params(self):

assert response.status_code == 400
assert response.json() == {
"workflow_id": ["This field is required."],
"workflow": ["This field is required."],
"ticket_id": ["This field is required."],
}

def test_create_happy_flow(self):
self.api_client.force_authenticate(user=self.curator)

data = {
"workflow_id": self.workflow.id,
"workflow": str(self.workflow.id),
"ticket_id": "dc94caad1b4f71502d06117a3b4bcb25",
"ticket_type": "author_create_user",
}
Expand All @@ -312,7 +312,7 @@ def test_create_happy_flow(self):

assert response.status_code == 201

assert "workflow_id" in response.data
assert "workflow" in response.data
assert "ticket_id" in response.data
assert "ticket_type" in response.data

Expand Down

0 comments on commit 5761f3f

Please sign in to comment.