|
| 1 | +{% extends 'generic/bulk_import.html' %} |
| 2 | +{% load form_helpers %} |
| 3 | +{% load helpers %} |
| 4 | +{% load i18n %} |
| 5 | + |
| 6 | + |
| 7 | +{% block content %} |
| 8 | + |
| 9 | + {# Data Import Form #} |
| 10 | + <div class="tab-pane show active" id="import-form" role="tabpanel" aria-labelledby="import-form-tab"> |
| 11 | + <div class="col col-md-12 col-lg-10 offset-lg-1"> |
| 12 | + |
| 13 | + {% if branch_warning %} |
| 14 | + {% include 'netbox_custom_objects/inc/branch_warning.html' %} |
| 15 | + {% endif %} |
| 16 | + |
| 17 | + <form action="" method="post" enctype="multipart/form-data" class="form"> |
| 18 | + {% csrf_token %} |
| 19 | + <input type="hidden" name="import_method" value="direct" /> |
| 20 | + |
| 21 | + {# Form fields #} |
| 22 | + {% render_field form.data %} |
| 23 | + {% render_field form.format %} |
| 24 | + {% render_field form.csv_delimiter %} |
| 25 | + |
| 26 | + {# Meta fields #} |
| 27 | + <div class="bg-primary-subtle border border-primary rounded-1 pt-3 px-3 mb-3"> |
| 28 | + {% if form.changelog_message %} |
| 29 | + {% render_field form.changelog_message %} |
| 30 | + {% endif %} |
| 31 | + {% render_field form.background_job %} |
| 32 | + </div> |
| 33 | + |
| 34 | + <div class="form-group"> |
| 35 | + <div class="col col-md-12 text-end"> |
| 36 | + {% if return_url %} |
| 37 | + <a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a> |
| 38 | + {% endif %} |
| 39 | + <button type="submit" name="data_submit" class="btn btn-primary">{% trans "Submit" %}</button> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + </form> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + |
| 46 | + {# File Upload Form #} |
| 47 | + <div class="tab-pane show" id="upload-form" role="tabpanel" aria-labelledby="upload-form-tab"> |
| 48 | + <div class="col col-md-12 col-lg-10 offset-lg-1"> |
| 49 | + <form action="" method="post" enctype="multipart/form-data" class="form"> |
| 50 | + {% csrf_token %} |
| 51 | + <input type="hidden" name="import_method" value="upload" /> |
| 52 | + |
| 53 | + {# Form fields #} |
| 54 | + {% render_field form.upload_file %} |
| 55 | + {% render_field form.format %} |
| 56 | + {% render_field form.csv_delimiter %} |
| 57 | + |
| 58 | + {# Meta fields #} |
| 59 | + {# Background jobs not supported with file uploads #} |
| 60 | + {% if form.changelog_message %} |
| 61 | + <div class="bg-primary-subtle border border-primary rounded-1 pt-3 px-3 mb-3"> |
| 62 | + {% render_field form.changelog_message %} |
| 63 | + </div> |
| 64 | + {% endif %} |
| 65 | + |
| 66 | + <div class="form-group"> |
| 67 | + <div class="col col-md-12 text-end"> |
| 68 | + {% if return_url %} |
| 69 | + <a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a> |
| 70 | + {% endif %} |
| 71 | + <button type="submit" name="file_submit" class="btn btn-primary">{% trans "Submit" %}</button> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + </form> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + |
| 78 | + {# DataFile Form #} |
| 79 | + <div class="tab-pane show" id="datafile-form" role="tabpanel" aria-labelledby="datafile-form-tab"> |
| 80 | + <div class="col col-md-12 col-lg-10 offset-lg-1"> |
| 81 | + <form action="" method="post" enctype="multipart/form-data" class="form"> |
| 82 | + {% csrf_token %} |
| 83 | + <input type="hidden" name="import_method" value="datafile" /> |
| 84 | + |
| 85 | + {# Form fields #} |
| 86 | + {% render_field form.data_source %} |
| 87 | + {% render_field form.data_file %} |
| 88 | + {% render_field form.format %} |
| 89 | + {% render_field form.csv_delimiter %} |
| 90 | + |
| 91 | + {# Meta fields #} |
| 92 | + <div class="bg-primary-subtle border border-primary rounded-1 pt-3 px-3 mb-3"> |
| 93 | + {% if form.changelog_message %} |
| 94 | + {% render_field form.changelog_message %} |
| 95 | + {% endif %} |
| 96 | + {% render_field form.background_job %} |
| 97 | + </div> |
| 98 | + |
| 99 | + <div class="form-group"> |
| 100 | + <div class="col col-md-12 text-end"> |
| 101 | + {% if return_url %} |
| 102 | + <a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a> |
| 103 | + {% endif %} |
| 104 | + <button type="submit" name="file_submit" class="btn btn-primary">{% trans "Submit" %}</button> |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + </form> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + |
| 111 | + {% if fields %} |
| 112 | + <div class="row my-3"> |
| 113 | + <div class="col col-md-12"> |
| 114 | + <div class="card"> |
| 115 | + <h2 class="card-header">{% trans "Field Options" %}</h2> |
| 116 | + <table class="table"> |
| 117 | + <thead> |
| 118 | + <tr> |
| 119 | + <th>{% trans "Field" %}</th> |
| 120 | + <th>{% trans "Required" %}</th> |
| 121 | + <th>{% trans "Accessor" %}</th> |
| 122 | + <th>{% trans "Description" %}</th> |
| 123 | + </tr> |
| 124 | + </thead> |
| 125 | + <tbody> |
| 126 | + {% for name, field in fields.items %} |
| 127 | + <tr> |
| 128 | + <td class="font-monospace{% if field.required %} fw-bold{% endif %}"> |
| 129 | + {{ name }} |
| 130 | + </td> |
| 131 | + <td> |
| 132 | + {% if field.required %} |
| 133 | + {% checkmark True true="Required" %} |
| 134 | + {% else %} |
| 135 | + {{ ''|placeholder }} |
| 136 | + {% endif %} |
| 137 | + </td> |
| 138 | + {% if field.to_field_name %} |
| 139 | + <td class="font-monospace">{{ field.to_field_name }}</td> |
| 140 | + {% else %} |
| 141 | + <td>{{ ''|placeholder }}</td> |
| 142 | + {% endif %} |
| 143 | + <td> |
| 144 | + {% if field.help_text %} |
| 145 | + {{ field.help_text }} |
| 146 | + {% elif field.label %} |
| 147 | + {{ field.label }} |
| 148 | + {% endif %} |
| 149 | + {% if field.STATIC_CHOICES %} |
| 150 | + <a href="#" data-bs-toggle="modal" data-bs-target="#{{ name }}_choices" aria-label="{{ name }} {% trans "choices" %}"><i class="mdi mdi-help-circle"></i></a> |
| 151 | + <div class="modal fade" id="{{ name }}_choices" tabindex="-1" role="dialog"> |
| 152 | + <div class="modal-dialog" role="document"> |
| 153 | + <div class="modal-content"> |
| 154 | + <div class="modal-header"> |
| 155 | + <h5 class="modal-title"> |
| 156 | + <span class="font-monospace">{{ name }}</span> {% trans "Choices" %} |
| 157 | + </h5> |
| 158 | + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 159 | + </div> |
| 160 | + <table class="table table-striped modal-body"> |
| 161 | + <thead> |
| 162 | + <tr> |
| 163 | + <th>{% trans "Import Value" %}</th> |
| 164 | + <th>{% trans "Label" %}</th> |
| 165 | + </tr> |
| 166 | + </thead> |
| 167 | + <tbody> |
| 168 | + {% for value, label in field.choices %} |
| 169 | + {% if value %} |
| 170 | + <tr> |
| 171 | + <td><samp>{{ value }}</samp></td> |
| 172 | + <td>{{ label }}</td> |
| 173 | + </tr> |
| 174 | + {% endif %} |
| 175 | + {% endfor %} |
| 176 | + </tbody> |
| 177 | + </table> |
| 178 | + </div> |
| 179 | + </div> |
| 180 | + </div> |
| 181 | + {% endif %} |
| 182 | + {% if field|widget_type == 'dateinput' %} |
| 183 | + <br /><small class="text-muted">{% trans "Format: YYYY-MM-DD" %}</small> |
| 184 | + {% elif field|widget_type == 'checkboxinput' %} |
| 185 | + <br /><small class="text-muted">{% trans "Specify true or false" %}</small> |
| 186 | + {% endif %} |
| 187 | + </td> |
| 188 | + </tr> |
| 189 | + {% endfor %} |
| 190 | + </tbody> |
| 191 | + </table> |
| 192 | + </div> |
| 193 | + </div> |
| 194 | + </div> |
| 195 | + <p class="small text-muted"> |
| 196 | + <i class="mdi mdi-check-bold text-success"></i> |
| 197 | + {% blocktrans trimmed %} |
| 198 | + Required fields <strong>must</strong> be specified for all objects. |
| 199 | + {% endblocktrans %} |
| 200 | + </p> |
| 201 | + <p class="small text-muted"> |
| 202 | + <i class="mdi mdi-information-outline"></i> |
| 203 | + {% blocktrans trimmed with example="vrf.rd" %} |
| 204 | + Related objects may be referenced by any unique attribute. For example, <code>{{ example }}</code> would identify a VRF by its route distinguisher. |
| 205 | + {% endblocktrans %} |
| 206 | + </p> |
| 207 | + {% endif %} |
| 208 | + |
| 209 | +{% endblock content %} |
0 commit comments