|
4 | 4 | import traceback |
5 | 5 | import tracemalloc |
6 | 6 | from typing import Iterable |
| 7 | +from packaging.version import Version |
7 | 8 |
|
8 | 9 | from django.forms import HiddenInput |
9 | 10 | from django.templatetags.static import static |
|
16 | 17 | from diffsync.enum import DiffSyncFlags |
17 | 18 | import structlog |
18 | 19 |
|
| 20 | +from nautobot import __version__ as nautobot_version |
19 | 21 | from nautobot.extras.jobs import BaseJob, BooleanVar |
20 | 22 |
|
21 | 23 | from nautobot_ssot.choices import SyncLogEntryActionChoices |
@@ -268,9 +270,12 @@ def __init__(self): |
268 | 270 | # Default diffsync flags. You can overwrite them at any time. |
269 | 271 | self.diffsync_flags = DiffSyncFlags.CONTINUE_ON_FAILURE | DiffSyncFlags.LOG_UNCHANGED_RECORDS |
270 | 272 |
|
271 | | - def as_form(self, data=None, files=None, initial=None): |
| 273 | + def as_form(self, data=None, files=None, initial=None, approval_view=False): |
272 | 274 | """Render this instance as a Django form for user inputs, including a "Dry run" field.""" |
273 | | - form = super().as_form(data=data, files=files, initial=initial) |
| 275 | + if Version(nautobot_version) < Version("1.2"): |
| 276 | + form = super().as_form(data=data, files=files, initial=initial) |
| 277 | + else: |
| 278 | + form = super().as_form(data=data, files=files, initial=initial, approval_view=approval_view) |
274 | 279 | # Set the "dry_run" widget's initial value based on our Meta attribute, if any |
275 | 280 | form.fields["dry_run"].initial = getattr(self.Meta, "dry_run_default", True) |
276 | 281 | # Hide the "commit" widget to reduce user confusion |
|
0 commit comments