obj_bulk_import.html 6.9 KB

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