No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

obj_create.html 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {% extends "base.html" %}
  2. {% load crispy_forms_tags %}
  3. {% block content %}
  4. <div class="row">
  5. <div class="col-sm-12">
  6. <div class="panel panel-default">
  7. <div class="panel-heading">Header</div>
  8. <div class="panel-body">
  9. <form method="post" action="#">
  10. {% csrf_token %}
  11. {{ form | crispy }}
  12. <button type="submit" class="btn btn-primary">Create</button>
  13. </form>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. <script>
  19. function getSubnet() {
  20. var netInp = $('#div_id_prefix input');
  21. netInp.val("");
  22. netInp.attr("placeholder", "Getting network...");
  23. var parentNetOpt = $('#id_parentNet option:selected');
  24. if(parentNetOpt.val()) {
  25. $.get("{% url "api:inetnum-get-subnet" %}", {net: parentNetOpt.text()}, function(data) {
  26. if(data.success) {
  27. netInp.attr("placeholder", "")
  28. netInp.val(data.network);
  29. } else {
  30. errorMsg = "Nothing returned via API";
  31. if(data.errorMsg)
  32. errorMsg = data.errorMsg;
  33. netInp.attr("placeholder", data.errorMsg);
  34. }
  35. });
  36. } else {
  37. netInp.attr("placeholder", "No Parent Range selected!");
  38. }
  39. }
  40. $(document).ready(function() {
  41. $('#div_id_prefix label').append(' <small>(<a onClick="getSubnet();">autofill network</a>)</small>');
  42. });
  43. </script>
  44. {% endblock %}