Rename base URL 'inventory.devices' => 'inventory'

This commit is contained in:
Santiago L 2022-03-15 14:33:27 +01:00
parent b4b12da477
commit 754f75eab4
22 changed files with 64 additions and 67 deletions

View File

@ -35,8 +35,7 @@ from ereuse_devicehub.resources.hash_reports import insert_hash
from ereuse_devicehub.resources.lot.models import Lot
from ereuse_devicehub.resources.tag.model import Tag
# TODO(@slamora): rename base 'inventory.devices' --> 'inventory'
devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory')
devices = Blueprint('inventory', __name__, url_prefix='/inventory')
logger = logging.getLogger(__name__)
@ -171,7 +170,7 @@ class LotDeviceAddView(View):
else:
messages.error('Error adding devices to lot!')
next_url = request.referrer or url_for('inventory.devices.devicelist')
next_url = request.referrer or url_for('inventory.devicelist')
return flask.redirect(next_url)
@ -191,7 +190,7 @@ class LotDeviceDeleteView(View):
else:
messages.error('Error removing devices from lot!')
next_url = request.referrer or url_for('inventory.devices.devicelist')
next_url = request.referrer or url_for('inventory.devicelist')
return flask.redirect(next_url)
@ -205,7 +204,7 @@ class LotCreateView(GenericMixView):
form = LotForm()
if form.validate_on_submit():
form.save()
next_url = url_for('inventory.devices.lotdevicelist', lot_id=form.id)
next_url = url_for('inventory.lotdevicelist', lot_id=form.id)
return flask.redirect(next_url)
lots = self.get_lots()
@ -228,7 +227,7 @@ class LotUpdateView(View):
form = LotForm(id=id)
if form.validate_on_submit():
form.save()
next_url = url_for('inventory.devices.lotdevicelist', lot_id=id)
next_url = url_for('inventory.lotdevicelist', lot_id=id)
return flask.redirect(next_url)
lots = Lot.query.filter(Lot.owner_id == current_user.id)
@ -251,11 +250,11 @@ class LotDeleteView(View):
if form.instance.trade:
msg = "Sorry, the lot cannot be deleted because have a trade action "
messages.error(msg)
next_url = url_for('inventory.devices.lotdevicelist', lot_id=id)
next_url = url_for('inventory.lotdevicelist', lot_id=id)
return flask.redirect(next_url)
form.remove()
next_url = url_for('inventory.devices.devicelist')
next_url = url_for('inventory.devicelist')
return flask.redirect(next_url)
@ -302,9 +301,9 @@ class DeviceCreateView(GenericMixView):
}
if form.validate_on_submit():
snapshot = form.save(commit=False)
next_url = url_for('inventory.devices.devicelist')
next_url = url_for('inventory.devicelist')
if lot_id:
next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
next_url = url_for('inventory.lotdevicelist', lot_id=lot_id)
lot = lots.filter(Lot.id == lot_id).one()
lot.devices.add(snapshot.device)
db.session.add(lot)
@ -344,7 +343,7 @@ class TagAddView(View):
form = TagForm()
if form.validate_on_submit():
form.save()
next_url = url_for('inventory.devices.taglist')
next_url = url_for('inventory.taglist')
return flask.redirect(next_url)
return flask.render_template(self.template_name, form=form, **context)
@ -376,7 +375,7 @@ class TagAddUnnamedView(View):
)
messages.error(msg)
next_url = url_for('inventory.devices.taglist')
next_url = url_for('inventory.taglist')
return flask.redirect(next_url)
return flask.render_template(self.template_name, form=form, **context)
@ -425,7 +424,7 @@ class TagUnlinkDeviceView(View):
if form.validate_on_submit():
form.remove()
next_url = url_for('inventory.devices.devicelist')
next_url = url_for('inventory.devicelist')
return flask.redirect(next_url)
return flask.render_template(
@ -458,9 +457,9 @@ class NewActionView(View):
lot_id = self.form.lot.data
if lot_id:
return url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
return url_for('inventory.lotdevicelist', lot_id=lot_id)
return url_for('inventory.devices.devicelist')
return url_for('inventory.devicelist')
class NewAllocateView(NewActionView, DeviceListMix):
@ -542,7 +541,7 @@ class NewTradeDocumentView(View):
if self.form.validate_on_submit():
self.form.save()
messages.success('Document created successfully!')
next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
next_url = url_for('inventory.lotdevicelist', lot_id=lot_id)
return flask.redirect(next_url)
return flask.render_template(

View File

@ -5,7 +5,7 @@
<header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between">
<a href="{{ url_for('inventory.devices.devicelist')}}" class="logo d-flex align-items-center">
<a href="{{ url_for('inventory.devicelist')}}" class="logo d-flex align-items-center">
<img src="{{ url_for('static', filename='img/usody-logo-black.svg') }}" alt="">
</a>
<i class="bi bi-list toggle-sidebar-btn"></i>
@ -90,7 +90,7 @@
</li><!-- End Dashboard Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="{{ url_for('inventory.devices.devicelist') }}">
<a class="nav-link collapsed" href="{{ url_for('inventory.devicelist') }}">
<i class="bi-menu-button-wide"></i>
<span>Unassigned devices</span>
</a>
@ -114,7 +114,7 @@
{% for lot in lots %}
{% if lot.is_incoming %}
<li>
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot.id) }}">
<a href="{{ url_for('inventory.lotdevicelist', lot_id=lot.id) }}">
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
</a>
</li>
@ -139,7 +139,7 @@
{% for lot in lots %}
{% if lot.is_outgoing %}
<li>
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot.id) }}">
<a href="{{ url_for('inventory.lotdevicelist', lot_id=lot.id) }}">
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
</a>
</li>
@ -162,14 +162,14 @@
<ul id="temporal-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
{% endif %}
<li>
<a href="{{ url_for('inventory.devices.lot_add')}}">
<a href="{{ url_for('inventory.lot_add')}}">
<i class="bi bi-plus" style="font-size: larger;"></i><span>New temporary lot</span>
</a>
</li>
{% for lot in lots %}
{% if lot.is_temporary %}
<li>
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot.id) }}">
<a href="{{ url_for('inventory.lotdevicelist', lot_id=lot.id) }}">
<i class="bi bi-circle"></i><span>{{ lot.name }}</span>
</a>
</li>
@ -181,7 +181,7 @@
<li class="nav-heading">Utils</li>
<li class="nav-item">
<a class="nav-link collapsed" href="{{ url_for('inventory.devices.taglist')}}">
<a class="nav-link collapsed" href="{{ url_for('inventory.taglist')}}">
<i class="bi bi-tags"></i>
<span>Tags</span>
</a>

View File

@ -7,7 +7,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.action_add') }}" method="post">
<form action="{{ url_for('inventory.action_add') }}" method="post">
{{ form_new_action.csrf_token }}
<div class="modal-body">
{% for field in form_new_action %}

View File

@ -7,7 +7,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.lot_devices_add') }}" method="post">
<form action="{{ url_for('inventory.lot_devices_add') }}" method="post">
{{ form_lot_device.csrf_token }}
<div class="modal-body">
Please write a name of a lot

View File

@ -7,7 +7,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.tag_devices_add') }}" method="post">
<form action="{{ url_for('inventory.tag_devices_add') }}" method="post">
{{ form_tag_device.csrf_token }}
<div class="modal-body">
Please write a name of a tag

View File

@ -8,7 +8,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.allocate_add') }}" method="post">
<form action="{{ url_for('inventory.allocate_add') }}" method="post">
{{ form_new_allocate.csrf_token }}
<div class="modal-body">
{% for field in form_new_allocate %}

View File

@ -8,7 +8,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.datawipe_add') }}" method="post" enctype="multipart/form-data">
<form action="{{ url_for('inventory.datawipe_add') }}" method="post" enctype="multipart/form-data">
{{ form_new_datawipe.csrf_token }}
<div class="modal-body">
{% for field in form_new_datawipe %}

View File

@ -5,7 +5,7 @@
<h1>{{ page_title }}</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item">{{ page_title }}</li>
</ol>
</nav>
@ -371,9 +371,9 @@
<div>
{% if lot_id %}
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot_id) }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.lotdevicelist', lot_id=lot_id) }}" class="btn btn-danger">Cancel</a>
{% else %}
<a href="{{ url_for('inventory.devices.devicelist') }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.devicelist') }}" class="btn btn-danger">Cancel</a>
{% endif %}
<button class="btn btn-primary" type="submit">Save</button>
</div>

View File

@ -5,7 +5,7 @@
<h1>Inventory</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item active">{{ page_title }}</li>
</ol>
</nav>

View File

@ -5,7 +5,7 @@
<h1>Inventory</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devicelist')}}">Inventory</a></li>
{% if not lot %}
<li class="breadcrumb-item active">Unassgined</li>
{% elif lot.is_temporary %}
@ -33,7 +33,7 @@
<!-- Bordered Tabs -->
<div class="d-flex align-items-center justify-content-between">
<h3><a href="{{ url_for('inventory.devices.lot_edit', id=lot.id) }}">{{ lot.name }}</a></h3>
<h3><a href="{{ url_for('inventory.lot_edit', id=lot.id) }}">{{ lot.name }}</a></h3>
<div><!-- lot actions -->
{% if lot.is_temporary %}
@ -246,9 +246,9 @@
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
<li>
{% if lot %}
<a href="{{ url_for('inventory.devices.lot_upload_snapshot', lot_id=lot.id) }}" class="dropdown-item">
<a href="{{ url_for('inventory.lot_upload_snapshot', lot_id=lot.id) }}" class="dropdown-item">
{% else %}
<a href="{{ url_for('inventory.devices.upload_snapshot') }}" class="dropdown-item">
<a href="{{ url_for('inventory.upload_snapshot') }}" class="dropdown-item">
{% endif %}
<i class="bi bi-plus"></i>
Upload a new Snapshot
@ -256,9 +256,9 @@
</li>
<li>
{% if lot %}
<a href="{{ url_for('inventory.devices.lot_device_add', lot_id=lot.id) }}" class="dropdown-item">
<a href="{{ url_for('inventory.lot_device_add', lot_id=lot.id) }}" class="dropdown-item">
{% else %}
<a href="{{ url_for('inventory.devices.device_add') }}" class="dropdown-item">
<a href="{{ url_for('inventory.device_add') }}" class="dropdown-item">
{% endif %}
<i class="bi bi-plus"></i>
Create a new Device
@ -275,7 +275,7 @@
</button>
<ul class="dropdown-menu" aria-labelledby="btnSnapshot">
<li>
<a href="{{ url_for('inventory.devices.trade_document_add', lot_id=lot.id)}}" class="dropdown-item">
<a href="{{ url_for('inventory.trade_document_add', lot_id=lot.id)}}" class="dropdown-item">
<i class="bi bi-plus"></i>
Add new document
<span class="caret"></span>
@ -324,18 +324,18 @@
/>
</td>
<td>
<a href="{{ url_for('inventory.devices.device_details', id=dev.devicehub_id)}}">
<a href="{{ url_for('inventory.device_details', id=dev.devicehub_id)}}">
{{ dev.verbose_name }}
</a>
</td>
<td>
<a href="{{ url_for('inventory.devices.device_details', id=dev.devicehub_id)}}">
<a href="{{ url_for('inventory.device_details', id=dev.devicehub_id)}}">
{{ dev.devicehub_id }}
</a>
</td>
<td>
{% for t in dev.tags | sort(attribute="id") %}
<a href="{{ url_for('inventory.devices.tag_details', id=t.id)}}">{{ t.id }}</a>
<a href="{{ url_for('inventory.tag_details', id=t.id)}}">{{ t.id }}</a>
{% if not loop.last %},{% endif %}
{% endfor %}
</td>

View File

@ -44,9 +44,9 @@
<div>
{% if form.id %}
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=form.id) }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.lotdevicelist', lot_id=form.id) }}" class="btn btn-danger">Cancel</a>
{% else %}
<a href="{{ url_for('inventory.devices.devicelist') }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.devicelist') }}" class="btn btn-danger">Cancel</a>
{% endif %}
<button class="btn btn-primary" type="submit">Save</button>
</div>

View File

@ -6,7 +6,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.lot_devices_del') }}" method="post">
<form action="{{ url_for('inventory.lot_devices_del') }}" method="post">
{{ form_lot_device.csrf_token }}
<div class="modal-body">
Please write a name of a lot

View File

@ -16,7 +16,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<a href="{{ url_for('inventory.devices.lot_del', id=lot.id)}}" type="button" class="btn btn-primary">
<a href="{{ url_for('inventory.lot_del', id=lot.id)}}" type="button" class="btn btn-primary">
Confirm
</a>
</div>

View File

@ -5,7 +5,7 @@
<h1>{{ title }}</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item">{{ page_title }}</li>
</ol>
</nav>
@ -49,7 +49,7 @@
</div>
<div>
<a href="{{ url_for('inventory.devices.taglist') }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.taglist') }}" class="btn btn-danger">Cancel</a>
<button class="btn btn-primary" type="submit">Save</button>
</div>
</form>

View File

@ -5,7 +5,7 @@
<h1>{{ title }}</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item">{{ page_title }}</li>
</ol>
</nav>
@ -49,7 +49,7 @@
</div>
<div>
<a href="{{ url_for('inventory.devices.taglist') }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.taglist') }}" class="btn btn-danger">Cancel</a>
<button class="btn btn-primary" type="submit">Save</button>
</div>
</form>

View File

@ -5,7 +5,7 @@
<h1>Inventory</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item active">Tag details {{ tag.id }}</li>
</ol>
</nav>
@ -33,7 +33,7 @@
<div class="col-lg-3 col-md-4 label">Device</div>
<div class="col-lg-9 col-md-8">
{% if tag.device %}
<a href="{{url_for('inventory.devices.device_details', id=tag.device.devicehub_id)}}">
<a href="{{url_for('inventory.device_details', id=tag.device.devicehub_id)}}">
{{ tag.device.verbose_name }}
</a>
{% endif %}
@ -109,6 +109,6 @@
<script src="{{ url_for('static', filename='js/jspdf.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/print.pdf.js') }}"></script>
<script type="text/javascript">
qr_draw("{{url_for('inventory.devices.device_details', id=tag.device.devicehub_id, _external=True)}}");
qr_draw("{{url_for('inventory.device_details', id=tag.device.devicehub_id, _external=True)}}");
</script>
{% endblock main %}

View File

@ -20,7 +20,7 @@
<!-- Bordered Tabs -->
<div class="btn-group dropdown ml-1">
<a href="{{ url_for('inventory.devices.tag_add')}}" type="button" class="btn btn-primary">
<a href="{{ url_for('inventory.tag_add')}}" type="button" class="btn btn-primary">
<i class="bi bi-plus"></i>
Create Named Tag
<span class="caret"></span>
@ -28,7 +28,7 @@
</div>
<div class="btn-group dropdown ml-1" uib-dropdown="">
<a href="{{ url_for('inventory.devices.tag_unnamed_add')}}" type="button" class="btn btn-primary">
<a href="{{ url_for('inventory.tag_unnamed_add')}}" type="button" class="btn btn-primary">
<i class="bi bi-plus"></i>
Create UnNamed Tag
<span class="caret"></span>
@ -52,12 +52,12 @@
<tbody>
{% for tag in tags %}
<tr>
<td><a href="{{ url_for('inventory.devices.tag_details', id=tag.id) }}">{{ tag.id }}</a></td>
<td><a href="{{ url_for('inventory.tag_details', id=tag.id) }}">{{ tag.id }}</a></td>
<td>{% if tag.provider %}Unnamed tag {% else %}Named tag{% endif %}</td>
<td>{{ tag.get_provider }}</td>
<td>
{% if tag.device %}
<a href={{ url_for('inventory.devices.device_details', id=tag.device.devicehub_id)}}>
<a href={{ url_for('inventory.device_details', id=tag.device.devicehub_id)}}>
{{ tag.device.verbose_name }}
</a>
{% endif %}

View File

@ -4,7 +4,7 @@
<div class="pagetitle">
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item">Unlink Tag from Device</li>
</ol>
</nav>

View File

@ -9,7 +9,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="{{ url_for('inventory.devices.trade_add') }}" method="post">
<form action="{{ url_for('inventory.trade_add') }}" method="post">
{{ form_new_trade.csrf_token }}
<div class="modal-body">
{% for field in form_new_trade %}

View File

@ -30,7 +30,7 @@
{% endif %}
</div>
<form action="{{ url_for('inventory.devices.trade_document_add', lot_id=form._lot.id) }}" method="post"
<form action="{{ url_for('inventory.trade_document_add', lot_id=form._lot.id) }}" method="post"
class="row g-3 needs-validation" enctype="multipart/form-data">
{{ form.csrf_token }}
{% for field in form %}
@ -51,7 +51,7 @@
{% endfor %}
<div>
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=form._lot.id) }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.lotdevicelist', lot_id=form._lot.id) }}" class="btn btn-danger">Cancel</a>
<button class="btn btn-primary" type="submit">Save</button>
</div>
</form>

View File

@ -5,7 +5,7 @@
<h1>Inventory</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item active">{{ page_title }}</li>
</ol>
</nav>
@ -56,9 +56,9 @@
<div>
{% if lot_id %}
<a href="{{ url_for('inventory.devices.lotdevicelist', lot_id=lot_id) }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.lotdevicelist', lot_id=lot_id) }}" class="btn btn-danger">Cancel</a>
{% else %}
<a href="{{ url_for('inventory.devices.devicelist') }}" class="btn btn-danger">Cancel</a>
<a href="{{ url_for('inventory.devicelist') }}" class="btn btn-danger">Cancel</a>
{% endif %}
<button class="btn btn-primary" type="submit">Send</button>
</div>

View File

@ -29,9 +29,7 @@ class LoginView(View):
if not is_safe_url(flask.request, next_url):
return flask.abort(400)
return flask.redirect(
next_url or flask.url_for('inventory.devices.devicelist')
)
return flask.redirect(next_url or flask.url_for('inventory.devicelist'))
context = {'form': form, 'version': __version__}
return flask.render_template('ereuse_devicehub/user_login.html', **context)