Skip to content

Commit 7433774

Browse files
committed
fix lint
1 parent b9a5548 commit 7433774

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

django_forms_workflows/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from django.contrib import admin
9+
from django.db import transaction
910
from django.urls import path, reverse
1011
from django.utils.html import format_html
1112

@@ -204,7 +205,6 @@ def clone_link(self, obj):
204205

205206
def clone_forms(self, request, queryset):
206207
"""Admin action to clone selected forms"""
207-
from . import form_builder_views
208208

209209
cloned_count = 0
210210
for form in queryset:

django_forms_workflows/form_builder_views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
import uuid
1111

1212
from django.contrib.admin.views.decorators import staff_member_required
13-
from django.contrib.auth.decorators import login_required
1413
from django.db import transaction
1514
from django.http import JsonResponse
1615
from django.shortcuts import get_object_or_404, render
1716
from django.views.decorators.http import require_GET, require_POST
1817

19-
from .forms import DynamicForm
2018
from .models import FormDefinition, FormField, FormTemplate, PrefillSource
2119

2220
logger = logging.getLogger(__name__)
@@ -469,6 +467,7 @@ def form_builder_preview(request):
469467
# Use actual DynamicForm rendering with crispy forms
470468
# We'll create temporary objects in a rolled-back transaction
471469
from django.db import transaction
470+
472471
from .forms import DynamicForm
473472

474473
with transaction.atomic():
@@ -528,7 +527,7 @@ def form_builder_preview(request):
528527
dynamic_form = DynamicForm(form_definition)
529528

530529
# Render the form using crispy forms template rendering
531-
from django.template import Template, Context
530+
from django.template import Context, Template
532531

533532
# Use crispy forms to render the form properly
534533
template_string = """

django_forms_workflows/management/commands/create_default_templates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from django.core.management.base import BaseCommand
9+
910
from django_forms_workflows.models import FormTemplate
1011

1112

django_forms_workflows/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
and submission management.
66
"""
77

8+
import json
89
import logging
910
from datetime import date, datetime, time
1011
from decimal import Decimal
@@ -16,7 +17,6 @@
1617
from django.shortcuts import get_object_or_404, redirect, render
1718
from django.utils import timezone
1819
from django.views.decorators.http import require_http_methods
19-
import json
2020

2121
from .forms import DynamicForm
2222
from .models import ApprovalTask, AuditLog, FormDefinition, FormSubmission

django_forms_workflows/workflow_builder_views.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
import logging
99

1010
from django.contrib.admin.views.decorators import staff_member_required
11-
from django.contrib.auth.decorators import login_required
1211
from django.contrib.auth.models import Group
1312
from django.db import transaction
1413
from django.http import JsonResponse
1514
from django.shortcuts import get_object_or_404, render
1615
from django.views.decorators.http import require_GET, require_POST
1716

18-
from .models import FormDefinition, WorkflowDefinition, PostSubmissionAction
17+
from .models import FormDefinition, PostSubmissionAction, WorkflowDefinition
1918

2019
logger = logging.getLogger(__name__)
2120

@@ -169,12 +168,11 @@ def convert_workflow_to_visual(workflow, form_definition):
169168
node_id_counter = 1
170169

171170
# Layout configuration for better spacing
172-
HORIZONTAL_SPACING = 280 # Increased from 200 for better readability
173-
VERTICAL_SPACING = 150
174-
START_X = 120
175-
START_Y = 200
176-
current_x = START_X
177-
current_y = START_Y
171+
horizontal_spacing = 280 # Increased from 200 for better readability
172+
start_x = 120
173+
start_y = 200
174+
current_x = start_x
175+
current_y = start_y
178176

179177
# Start node (always present)
180178
start_node = {
@@ -187,7 +185,7 @@ def convert_workflow_to_visual(workflow, form_definition):
187185
nodes.append(start_node)
188186
last_node_id = start_node["id"]
189187
node_id_counter += 1
190-
current_x += HORIZONTAL_SPACING
188+
current_x += horizontal_spacing
191189

192190
# Form submission node (always present - represents the actual form)
193191
form_fields = list(form_definition.fields.all().order_by("order"))
@@ -235,7 +233,7 @@ def convert_workflow_to_visual(workflow, form_definition):
235233
)
236234
last_node_id = form_node["id"]
237235
node_id_counter += 1
238-
current_x += HORIZONTAL_SPACING
236+
current_x += horizontal_spacing
239237

240238
# Approval configuration node (always present - shows approval requirements)
241239
approval_groups = list(workflow.approval_groups.all())
@@ -270,7 +268,7 @@ def convert_workflow_to_visual(workflow, form_definition):
270268
)
271269
last_node_id = approval_config_node["id"]
272270
node_id_counter += 1
273-
current_x += HORIZONTAL_SPACING
271+
current_x += horizontal_spacing
274272

275273
# Manager approval node (if enabled)
276274
if workflow.requires_manager_approval:
@@ -293,13 +291,13 @@ def convert_workflow_to_visual(workflow, form_definition):
293291
)
294292
last_node_id = manager_node["id"]
295293
node_id_counter += 1
296-
current_x += HORIZONTAL_SPACING
294+
current_x += horizontal_spacing
297295

298296
# Group approval nodes (already fetched above)
299297
if approval_groups:
300298
if workflow.approval_logic == "sequence":
301299
# Sequential nodes - horizontal flow
302-
for i, group in enumerate(approval_groups):
300+
for group in approval_groups:
303301
group_node = {
304302
"id": f"node_{node_id_counter}",
305303
"type": "approval",
@@ -321,7 +319,7 @@ def convert_workflow_to_visual(workflow, form_definition):
321319
)
322320
last_node_id = group_node["id"]
323321
node_id_counter += 1
324-
current_x += HORIZONTAL_SPACING
322+
current_x += horizontal_spacing
325323
else:
326324
# Parallel nodes (all/any)
327325
parallel_node = {
@@ -345,13 +343,13 @@ def convert_workflow_to_visual(workflow, form_definition):
345343
)
346344
last_node_id = parallel_node["id"]
347345
node_id_counter += 1
348-
current_x += HORIZONTAL_SPACING
346+
current_x += horizontal_spacing
349347

350348
# Post-submission actions
351349
actions = form_definition.post_actions.filter(is_active=True).order_by("order")
352350

353351
# Actions continue on the same horizontal line for a cleaner flow
354-
for i, action in enumerate(actions):
352+
for action in actions:
355353
# Determine node type based on action type
356354
node_type = "email" if action.action_type == "email" else "action"
357355

@@ -418,7 +416,7 @@ def convert_workflow_to_visual(workflow, form_definition):
418416
)
419417
last_node_id = action_node["id"]
420418
node_id_counter += 1
421-
current_x += HORIZONTAL_SPACING
419+
current_x += horizontal_spacing
422420

423421
# End node
424422
end_node = {
@@ -448,10 +446,8 @@ def convert_visual_to_workflow(workflow_data, form_definition):
448446
"""
449447
Convert visual workflow format to WorkflowDefinition model.
450448
"""
451-
from .models import PostSubmissionAction
452449

453450
nodes = workflow_data.get("nodes", [])
454-
connections = workflow_data.get("connections", [])
455451

456452
# Extract workflow configuration from nodes
457453
requires_approval = False

0 commit comments

Comments
 (0)