ohtu2021-kvantti/WebMark

View on GitHub
templates/WebCLI/addVersion.html

Summary

Maintainability
Test Coverage
{% extends 'base.html' %}

{% load bootstrap4 %}

{% block title %}Update algorithm{% endblock %}

{% block content %}
    <div class="p-12">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Update algorithm</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <th>name</th>
                    <td>{{ algorithm.name }}</td>
                </tr>
                <tr>
                    <th>type</th>
                    <td>{{ algorithm.algorithm_type.type_name }}</td>
                </tr>
            </tbody>
        </table>
    </div>

    <form method="post" method-url="{% url 'load_methods' %}" id="versionForm">
        {% csrf_token %}
        {% bootstrap_form form %}
        {% buttons %}
        <div class="text-center">
            <button class="btn btn-primary" type="submit">Submit</button>
        </div>
        {% endbuttons %}
    </form>

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script>
        $("#id_optimizer_module").change(function () {
            var url = $("#versionForm").attr("method-url")
            var module = $(this).val();

            $.ajax({ 
                url: url, 
                data: {
                    'module': module 
                },
                success: function (data) { 
                    $("#id_optimizer_method").html(data);
                }
            });

        });
    </script>
{% endblock %}