Skip to content

Commit

Permalink
#334 Disable branch delete button (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
viliambalaz authored May 10, 2021
1 parent 7e6fb4f commit 448e1b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions chcemvediet/apps/inforequests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ def get_inforequest(self, obj):
return obj.branch.inforequest

def delete_constraints(self, obj):
dependency = []
constraints = []
if obj.type in [Action.TYPES.REQUEST, Action.TYPES.ADVANCED_REQUEST]:
dependency.append(format_html(
constraints.append(format_html(
u'{} is type {}.'.format(admin_obj_format(obj), obj.get_type_display())))
if len(obj.branch.actions) == 1:
dependency.append(format_html(
constraints.append(format_html(
u'{} is the only action in the branch.'.format(admin_obj_format(obj))))
return dependency
return constraints

def render_delete_form(self, request, context):
context[u'delete_constraints'] = self.delete_constraints(context[u'object'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ul>{{ delete_constraints|unordered_list }}</ul>
</div>
{% endbefore %}
{% set_attributes path=".//form//input[@type='submit']" disabled=False %}
{% set_attributes path=".//form//input[@type='submit']" disabled=True %}
{% endif %}
{% endamend %}
{% endblock %}

0 comments on commit 448e1b7

Please sign in to comment.