Skip to content
Snippets Groups Projects
Commit 253fb69a authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Rename networks blueprint to network

Use endpoint argument to avoid collision with flask-admin Network
parent 3fb60886
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
File moved
# -*- 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.
......
# -*- 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')
......
......@@ -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);
});
......
......@@ -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>
......
......@@ -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 %}
......
......@@ -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>
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment