object_bulk_import.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {% extends 'layout.html' %}
  2. {% load helpers %}
  3. {% load form_helpers %}
  4. {% block title %}{{ obj_type|bettertitle }} Bulk Import{% endblock %}
  5. {% block content %}
  6. <div class="row">
  7. <div class="col col-md-8 offset-md-2">
  8. <ul class="nav nav-tabs mb-3" role="tablist">
  9. <li class="nav-item" role="presentation">
  10. <a href="#csv" class="nav-link active" role="tab" data-bs-toggle="tab">CSV</a>
  11. </li>
  12. </ul>
  13. <div class="tab-content">
  14. <div role="tabpanel" class="tab-pane active" id="csv">
  15. <form action="" method="post" class="form">
  16. {% csrf_token %}
  17. {% render_form form %}
  18. <div class="form-group">
  19. <div class="col col-md-12 text-end">
  20. {% if return_url %}
  21. <a href="{{ return_url }}" class="btn btn-outline-danger">Cancel</a>
  22. {% endif %}
  23. <button type="submit" class="btn btn-primary">Submit</button>
  24. </div>
  25. </div>
  26. </form>
  27. {% if fields %}
  28. <div class="row my-3">
  29. <div class="col col-md-12">
  30. <div class="card">
  31. <h5 class="card-header">
  32. CSV Field Options
  33. </h5>
  34. <div class="card-body">
  35. <table class="table">
  36. <tr>
  37. <th>Field</th>
  38. <th>Required</th>
  39. <th>Accessor</th>
  40. <th>Description</th>
  41. </tr>
  42. {% for name, field in fields.items %}
  43. <tr>
  44. <td>
  45. <code>{{ name }}</code>
  46. </td>
  47. <td>
  48. {% if field.required %}
  49. <i class="mdi mdi-check-bold text-success" title="Required"></i>
  50. {% else %}
  51. <span class="text-muted">&mdash;</span>
  52. {% endif %}
  53. </td>
  54. <td>
  55. {% if field.to_field_name %}
  56. <code>{{ field.to_field_name }}</code>
  57. {% else %}
  58. <span class="text-muted">&mdash;</span>
  59. {% endif %}
  60. </td>
  61. <td>
  62. {% if field.STATIC_CHOICES %}
  63. <button type="button" class="btn btn-link btn-sm float-end" data-bs-toggle="modal" data-bs-target="#{{ name }}_choices">
  64. <i class="mdi mdi-help-circle"></i>
  65. </button>
  66. <div class="modal fade" id="{{ name }}_choices" tabindex="-1" role="dialog">
  67. <div class="modal-dialog" role="document">
  68. <div class="modal-content">
  69. <div class="modal-header">
  70. <h5 class="modal-title"><code>{{ name }}</code> Choices</h5>
  71. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  72. </div>
  73. <div class="modal-body">
  74. <table class="table table-striped">
  75. <tr>
  76. <th>Import Value</th>
  77. <th>Label</th>
  78. </tr>
  79. {% for value, label in field.choices %}
  80. {% if value %}
  81. <tr>
  82. <td>
  83. <samp>{{ value }}</samp>
  84. </td>
  85. <td>
  86. {{ label }}
  87. </td>
  88. </tr>
  89. {% endif %}
  90. {% endfor %}
  91. </table>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. {% endif %}
  97. {% if field.help_text %}
  98. {{ field.help_text }}<br />
  99. {% elif field.label %}
  100. {{ field.label }}<br />
  101. {% endif %}
  102. {% if field|widget_type == 'dateinput' %}
  103. <small class="text-muted">Format: YYYY-MM-DD</small>
  104. {% elif field|widget_type == 'checkboxinput' %}
  105. <small class="text-muted">Specify "true" or "false"</small>
  106. {% endif %}
  107. </td>
  108. </tr>
  109. {% endfor %}
  110. </table>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <p class="small text-muted">
  116. <i class="mdi mdi-check-bold text-success"></i> Required fields <strong>must</strong> be specified for all
  117. objects.
  118. </p>
  119. <p class="small text-muted">
  120. <i class="mdi mdi-information-outline"></i> Related objects may be referenced by any unique attribute.
  121. For example, <code>vrf.rd</code> would identify a VRF by its route distinguisher.
  122. </p>
  123. {% endif %}
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. {% endblock %}