Skip to content

Commit ba98492

Browse files
committed
Prevent usage of a branch with pending migrations
1 parent e8648a7 commit ba98492

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

netbox_branching/models/branches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def is_active(self):
132132

133133
@property
134134
def ready(self):
135-
return self.status == BranchStatusChoices.READY
135+
return self.status == BranchStatusChoices.READY and not self.pending_migrations
136136

137137
@property
138138
def merged(self):

netbox_branching/templates/netbox_branching/buttons/branch_migrate.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% load i18n %}
2-
{% if perms.netbox_branching.migrate_branch and branch.ready %}
2+
3+
{% if perms.netbox_branching.migrate_branch and branch.status == 'ready' %}
34
<a href="{% url 'plugins:netbox_branching:branch_migrate' pk=branch.pk %}" class="btn btn-primary">
45
<i class="mdi mdi-step-forward"></i> {% trans "Migrate" %}
56
</a>

netbox_branching/templatetags/branch_buttons.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from django import template
22

3+
from netbox_branching.choices import BranchStatusChoices
4+
35
__all__ = (
46
'branch_sync_button',
57
'branch_merge_button',

netbox_branching/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def post(self, request, **kwargs):
341341
action_permitted = getattr(branch, f'can_merge')
342342
form = self.form(request.POST)
343343

344-
if not branch.ready:
344+
if branch.status != BranchStatusChoices.READY:
345345
messages.error(request, _("The branch is not ready to be migrated."))
346346
elif form.is_valid():
347347
# Enqueue a background job to migrate the Branch

0 commit comments

Comments
 (0)