1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Clean up and document the bulk import/edit/delete templates

This commit is contained in:
jeremystretch
2022-02-08 11:23:52 -05:00
parent b0039e938e
commit e796fd1e11
4 changed files with 63 additions and 37 deletions

View File

@@ -2,34 +2,44 @@
{% load helpers %}
{% load render_table from django_tables2 %}
{% block title %}Delete {{ table.rows|length }} {{ obj_type_plural|bettertitle }}?{% endblock %}
{% comment %}
Blocks:
message_extra: Supplementary warning message content
Context:
model: The model class of the objects being deleted
form: The bulk delete form class
table: The table class for rendering list of objects being deleted
return_url: The URL to which the user is redirected after submitting the form
{% endcomment %}
{% block title %}Delete {{ table.rows|length }} {{ model|meta:"verbose_name_plural"|bettertitle }}?{% endblock %}
{% block content %}
<div class="container-md px-0">
<div class="alert alert-danger mb-3" role="alert">
<h4 class="alert-heading">Confirm Bulk Deletion</h4>
<hr />
<div>
<strong>Warning:</strong> The following operation will delete <strong>{{ table.rows|length }}</strong> {{ obj_type_plural }}. Please carefully review the {{ obj_type_plural }} to be deleted and confirm below.
</div>
{% block message_extra %}{% endblock %}
<div class="container-md px-0">
<div class="alert alert-danger mb-3" role="alert">
<h4 class="alert-heading">Confirm Bulk Deletion</h4>
<hr />
<strong>Warning:</strong> The following operation will delete <strong>{{ table.rows|length }}</strong>
{{ model|meta:"verbose_name_plural" }}. Please carefully review the objects to be deleted and confirm below.
{% block message_extra %}{% endblock %}
</div>
</div>
<div class="container-xl px-0">
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
<div class="row mt-3">
<form action="" method="post">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
<div class="text-end">
<a href="{{ return_url }}" class="btn btn-outline-dark">Cancel</a>
<button type="submit" name="_confirm" class="btn btn-danger">Delete {{ table.rows|length }} {{ model|meta:"verbose_name_plural" }}</button>
</div>
</form>
</div>
<div class="container-xl px-0">
<div class="table-responsive">
{% render_table table 'inc/table.html' %}
</div>
<div class="row mt-3">
<form action="" method="post">
{% csrf_token %}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
<div class="text-end">
<a href="{{ return_url }}" class="btn btn-outline-dark">Cancel</a>
<button type="submit" name="_confirm" class="btn btn-danger">Delete {{ table.rows|length }} {{ obj_type_plural }}</button>
</div>
</form>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -3,7 +3,15 @@
{% load form_helpers %}
{% load render_table from django_tables2 %}
{% block title %}Editing {{ table.rows|length }} {{ model|meta:"verbose_name_plural" }}{% endblock %}
{% comment %}
Context:
model: The model class of the objects being modified
form: The bulk edit form class
table: The table class for rendering list of objects being modified
return_url: The URL to which the user is redirected after submitting the form
{% endcomment %}
{% block title %}Editing {{ table.rows|length }} {{ model|meta:"verbose_name_plural"|bettertitle }}{% endblock %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
@@ -19,7 +27,7 @@
</button>
</li>
</ul>
{% endblock %}
{% endblock tabs %}
{% block content-wrapper %}
<div class="tab-content">
@@ -128,6 +136,6 @@
</div>
</div>
{% endblock %}
{% endblock content %}
</div>
{% endblock %}
{% endblock content-wrapper %}

View File

@@ -2,7 +2,15 @@
{% load helpers %}
{% load form_helpers %}
{% block title %}{{ obj_type|bettertitle }} Bulk Import{% endblock %}
{% comment %}
Context:
model: The model class being imported
form: The bulk import form
fields: A dictionary of form fields, to display import options (optional)
return_url: The URL to which the user is redirected after submitting the form
{% endcomment %}
{% block title %}{{ model|meta:"verbose_name"|bettertitle }} Bulk Import{% endblock %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
@@ -10,7 +18,7 @@
<a class ="nav-link active" href="#">Bulk Import</a>
</li>
</ul>
{% endblock %}
{% endblock tabs %}
{% block content-wrapper %}
<div class="tab-content">
@@ -145,4 +153,4 @@
</div>
{% endblock content %}
</div>
{% endblock %}
{% endblock content-wrapper %}