object_bulk_import.html 6.6 KB

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