diff --git a/app/factory.py b/app/factory.py index f420f557ccc4688c3e75ced9204061a1d1500c3b..c9ed297a6c66630c625a22ccc64b0bd0ea0e2ffb 100644 --- a/app/factory.py +++ b/app/factory.py @@ -19,7 +19,7 @@ from .admin.views import (AdminModelView, ItemAdmin, UserAdmin, GroupAdmin, Toke NetworkAdmin) from .main.views import bp as main from .inventory.views import bp as inventory -from .networks.views import bp as networks +from .network.views import bp as network from .users.views import bp as users from .api.main import bp as api from .defaults import defaults @@ -110,14 +110,14 @@ def create_app(config=None): admin.add_view(ItemAdmin(models.Item, db.session)) admin.add_view(AdminModelView(models.ItemComment, db.session)) admin.add_view(AdminModelView(models.NetworkScope, db.session)) - admin.add_view(NetworkAdmin(models.Network, db.session)) + admin.add_view(NetworkAdmin(models.Network, db.session, endpoint='networks')) admin.add_view(AdminModelView(models.Interface, db.session)) admin.add_view(AdminModelView(models.Mac, db.session)) admin.add_view(AdminModelView(models.Cname, db.session)) app.register_blueprint(main) app.register_blueprint(inventory, url_prefix='/inventory') - app.register_blueprint(networks, url_prefix='/networks') + app.register_blueprint(network, url_prefix='/network') app.register_blueprint(users, url_prefix='/users') app.register_blueprint(api, url_prefix='/api') diff --git a/app/networks/__init__.py b/app/network/__init__.py similarity index 100% rename from app/networks/__init__.py rename to app/network/__init__.py diff --git a/app/networks/forms.py b/app/network/forms.py similarity index 96% rename from app/networks/forms.py rename to app/network/forms.py index 345e56b7afa5256e377942e6d4973a19318dd577..a8f2512966a1026978741c8ad3414ff27ed434b4 100644 --- a/app/networks/forms.py +++ b/app/network/forms.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """ -app.networks.forms -~~~~~~~~~~~~~~~~~~ +app.network.forms +~~~~~~~~~~~~~~~~~ -This module defines the networks blueprint forms. +This module defines the network blueprint forms. :copyright: (c) 2017 European Spallation Source ERIC :license: BSD 2-Clause, see LICENSE for more details. diff --git a/app/networks/views.py b/app/network/views.py similarity index 90% rename from app/networks/views.py rename to app/network/views.py index b8c0da70da480d573fa5b6d51565d3c3976221ac..82545893cbfeaf89a690dbd6d8dca241ec0cec09 100644 --- a/app/networks/views.py +++ b/app/network/views.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- """ -app.networks.views -~~~~~~~~~~~~~~~~~~ +app.network.views +~~~~~~~~~~~~~~~~~ -This module implements the networks blueprint. +This module implements the network blueprint. :copyright: (c) 2017 European Spallation Source ERIC :license: BSD 2-Clause, see LICENSE for more details. @@ -18,13 +18,13 @@ from ..extensions import db from ..decorators import login_groups_accepted from .. import models -bp = Blueprint('networks', __name__) +bp = Blueprint('network', __name__) @bp.route('/hosts') @login_required def list_hosts(): - return render_template('networks/hosts.html') + return render_template('network/hosts.html') @bp.route('/hosts/create', methods=('GET', 'POST')) @@ -63,8 +63,8 @@ def create_host(): flash(f'Host {host} created!', 'success') # Save network_id to the session to retrieve it after the redirect session['network_id'] = network_id - return redirect(url_for('networks.create_host')) - return render_template('networks/create_host.html', form=form) + return redirect(url_for('network.create_host')) + return render_template('network/create_host.html', form=form) @bp.route('/_retrieve_hosts') diff --git a/app/static/js/hosts.js b/app/static/js/hosts.js index 8594adc5560361b70c19b80725bfc2387a0628e0..4e26530322d8932085f92674e021875a8e0b580d 100644 --- a/app/static/js/hosts.js +++ b/app/static/js/hosts.js @@ -5,7 +5,7 @@ $(document).ready(function() { // and update the IP select field var network_id = $("#network_id").val(); $.getJSON( - $SCRIPT_ROOT + "/networks/_retrieve_available_ips/" + network_id, + $SCRIPT_ROOT + "/network/_retrieve_available_ips/" + network_id, function(json) { var $ip = $("#ip"); $ip.empty(); @@ -46,7 +46,7 @@ $(document).ready(function() { var hosts_table = $("#hosts_table").DataTable({ "ajax": function(data, callback, settings) { $.getJSON( - $SCRIPT_ROOT + "/networks/_retrieve_hosts", + $SCRIPT_ROOT + "/network/_retrieve_hosts", function(json) { callback(json); }); diff --git a/app/templates/base-fluid.html b/app/templates/base-fluid.html index 66f6708d339e671c48aceb2cb70b685770978fbf..41851c2aa2805c8b003013705bd11abe0c7051a0 100644 --- a/app/templates/base-fluid.html +++ b/app/templates/base-fluid.html @@ -16,9 +16,9 @@ href="{{ url_for('inventory.attributes', kind='Manufacturer') }}">Attributes</a> <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/inventory/qrcodes")) }}" href="{{ url_for('inventory.qrcodes', kind='Action') }}">QR Codes</a> - {% elif path.startswith("/networks") %} - <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/networks/hosts")) }}" - href="{{ url_for('networks.list_hosts') }}">Hosts</a> + {% elif path.startswith("/network") %} + <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/network/hosts")) }}" + href="{{ url_for('network.list_hosts') }}">Hosts</a> {% endif %} </div> </div> diff --git a/app/templates/base.html b/app/templates/base.html index f398c2331d510d8841d534a02a356732ad501f00..337657823badd8f383454c29f36562a6dac8c837 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -25,7 +25,7 @@ <div class="navbar-nav mr-auto"> {% set path = request.path %} <a class="nav-item nav-link {{ is_active(path.startswith("/inventory")) }}" href="{{ url_for('inventory.list_items') }}">Inventory</a> - <a class="nav-item nav-link {{ is_active(path.startswith("/networks")) }}" href="{{ url_for('networks.list_hosts') }}">Networks</a> + <a class="nav-item nav-link {{ is_active(path.startswith("/network")) }}" href="{{ url_for('network.list_hosts') }}">Network</a> {% if current_user.is_authenticated and current_user.is_admin %} <a class="nav-item nav-link" href="{{ url_for('admin.index') }}">Admin</a> {% endif %} diff --git a/app/templates/networks/create_host.html b/app/templates/network/create_host.html similarity index 84% rename from app/templates/networks/create_host.html rename to app/templates/network/create_host.html index a60b7c7e17ff4dc320625b346e0408584e6a1502..cbcb19ef99d04d9c912f8c7e29bf965cbe6604f3 100644 --- a/app/templates/networks/create_host.html +++ b/app/templates/network/create_host.html @@ -6,10 +6,10 @@ {% block main %} <ul class="nav nav-tabs"> <li class="nav-item"> - <a class="nav-link" href="{{ url_for('networks.list_hosts') }}">List hosts</a> + <a class="nav-link" href="{{ url_for('network.list_hosts') }}">List hosts</a> </li> <li class="nav-item"> - <a class="nav-link active" href="{{ url_for('networks.create_host') }}">Register new host</a> + <a class="nav-link active" href="{{ url_for('network.create_host') }}">Register new host</a> </li> </ul> diff --git a/app/templates/networks/hosts.html b/app/templates/network/hosts.html similarity index 78% rename from app/templates/networks/hosts.html rename to app/templates/network/hosts.html index 4a3a8fc732212935cf6fe61c13276ad0590208ee..b7519e3278fef38a362034a6e9f50dd99e3e4b66 100644 --- a/app/templates/networks/hosts.html +++ b/app/templates/network/hosts.html @@ -5,10 +5,10 @@ {% block main %} <ul class="nav nav-tabs"> <li class="nav-item"> - <a class="nav-link active" href="{{ url_for('networks.list_hosts') }}">List hosts</a> + <a class="nav-link active" href="{{ url_for('network.list_hosts') }}">List hosts</a> </li> <li class="nav-item"> - <a class="nav-link" href="{{ url_for('networks.create_host') }}">Register new host</a> + <a class="nav-link" href="{{ url_for('network.create_host') }}">Register new host</a> </li> </ul>