Set page_title & fix breadcrumb

This commit is contained in:
Santiago L 2022-02-02 11:41:29 +01:00
parent 44a38d4dec
commit c9a46128df
6 changed files with 35 additions and 28 deletions

View File

@ -9,6 +9,7 @@ from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, UploadSnapshotForm, \ from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, UploadSnapshotForm, \
NewDeviceForm, TagForm, TagUnnamedForm, TagDeviceForm NewDeviceForm, TagForm, TagUnnamedForm, TagDeviceForm
# TODO(@slamora): rename base 'inventory.devices' --> 'inventory'
devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory')
@ -44,7 +45,7 @@ class DeviceListView(View):
return flask.render_template(self.template_name, **context) return flask.render_template(self.template_name, **context)
class DeviceDetailsView(View): class DeviceDetailView(View):
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/device_details.html' template_name = 'inventory/device_details.html'
@ -168,54 +169,61 @@ class TagListView(View):
template_name = 'inventory/tag_list.html' template_name = 'inventory/tag_list.html'
def dispatch_request(self): def dispatch_request(self):
tags = Tag.query.filter( tags = Tag.query.filter(Tag.owner_id == current_user.id)
Tag.owner_id == current_user.id) context = {
context = {'tags': tags, 'lots': [],
'lots': []} 'tags': tags,
'page_title': 'Tags Management',
}
return flask.render_template(self.template_name, **context) return flask.render_template(self.template_name, **context)
class TagAddView(View): class TagAddView(View):
methods = ['GET', 'POST'] methods = ['GET', 'POST']
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/tag.html' template_name = 'inventory/tag_create.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'New Tag'}
form = TagForm() form = TagForm()
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
next_url = url_for('inventory.devices.taglist') next_url = url_for('inventory.devices.taglist')
return flask.redirect(next_url) return flask.redirect(next_url)
return flask.render_template(self.template_name, form=form) return flask.render_template(self.template_name, form=form, **context)
class TagAddUnnamedView(View): class TagAddUnnamedView(View):
methods = ['GET', 'POST'] methods = ['GET', 'POST']
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/tagUnnamed.html' template_name = 'inventory/tag_create_unnamed.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'New Unnamed Tag'}
form = TagUnnamedForm() form = TagUnnamedForm()
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
next_url = url_for('inventory.devices.taglist') next_url = url_for('inventory.devices.taglist')
return flask.redirect(next_url) return flask.redirect(next_url)
return flask.render_template(self.template_name, form=form) return flask.render_template(self.template_name, form=form, **context)
class TagDetailsView(View): class TagDetailView(View):
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/tag_details.html' template_name = 'inventory/tag_detail.html'
def dispatch_request(self, id): def dispatch_request(self, id):
lots = Lot.query.filter(Lot.owner_id == current_user.id) lots = Lot.query.filter(Lot.owner_id == current_user.id)
tag = Tag.query.filter( tag = Tag.query.filter(
Tag.owner_id == current_user.id).filter(Tag.id == id).one() Tag.owner_id == current_user.id).filter(Tag.id == id).one()
context = {'tag': tag, context = {
'lots': lots} 'lots': lots,
'tag': tag,
'page_title': '{} Tag'.format(tag.code),
}
return flask.render_template(self.template_name, **context) return flask.render_template(self.template_name, **context)
@ -249,7 +257,7 @@ class TagDeviceDeleteView(View):
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailsView.as_view('device_details')) devices.add_url_rule('/device/<string:id>/', view_func=DeviceDetailView.as_view('device_details'))
devices.add_url_rule('/lot/<string:lot_id>/device/', view_func=DeviceListView.as_view('lotdevicelist')) devices.add_url_rule('/lot/<string:lot_id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
devices.add_url_rule('/lot/devices/add/', view_func=LotDeviceAddView.as_view('lot_devices_add')) devices.add_url_rule('/lot/devices/add/', view_func=LotDeviceAddView.as_view('lot_devices_add'))
devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view('lot_devices_del')) devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view('lot_devices_del'))
@ -261,6 +269,6 @@ devices.add_url_rule('/device/add/', view_func=CreateDeviceView.as_view('device_
devices.add_url_rule('/tag/', view_func=TagListView.as_view('taglist')) devices.add_url_rule('/tag/', view_func=TagListView.as_view('taglist'))
devices.add_url_rule('/tag/add/', view_func=TagAddView.as_view('tag_add')) devices.add_url_rule('/tag/add/', view_func=TagAddView.as_view('tag_add'))
devices.add_url_rule('/tag/unnamed/add/', view_func=TagAddUnnamedView.as_view('tag_unnamed_add')) devices.add_url_rule('/tag/unnamed/add/', view_func=TagAddUnnamedView.as_view('tag_unnamed_add'))
devices.add_url_rule('/tag/<string:id>/', view_func=TagDetailsView.as_view('tag_details')) devices.add_url_rule('/tag/<string:id>/', view_func=TagDetailView.as_view('tag_details'))
devices.add_url_rule('/tag/devices/add/', view_func=TagDeviceAddView.as_view('tag_devices_add')) devices.add_url_rule('/tag/devices/add/', view_func=TagDeviceAddView.as_view('tag_devices_add'))
devices.add_url_rule('/tag/devices/<int:id>/del/', view_func=TagDeviceDeleteView.as_view('tag_devices_del')) devices.add_url_rule('/tag/devices/<int:id>/del/', view_func=TagDeviceDeleteView.as_view('tag_devices_del'))

View File

@ -1,4 +1,5 @@
{% extends "ereuse_devicehub/base.html" %} {% extends "ereuse_devicehub/base.html" %}
{% block page_title %}{{ page_title }}{% endblock %}
{% block body %} {% block body %}
<!-- ======= Header ======= --> <!-- ======= Header ======= -->
<header id="header" class="header fixed-top d-flex align-items-center"> <header id="header" class="header fixed-top d-flex align-items-center">

View File

@ -5,8 +5,8 @@
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item">Tag</li> <li class="breadcrumb-item">{{ page_title }}</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->

View File

@ -5,8 +5,8 @@
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item">Tag</li> <li class="breadcrumb-item">{{ page_title }}</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->
@ -19,7 +19,7 @@
<div class="card-body"> <div class="card-body">
<div class="pt-4 pb-2"> <div class="pt-4 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Add news Unnamed Tags</h5> <h5 class="card-title text-center pb-0 fs-4">Add new Unnamed Tags</h5>
<p class="text-center small">Please enter a number of the tags to issue.</p> <p class="text-center small">Please enter a number of the tags to issue.</p>
{% if form.form_errors %} {% if form.form_errors %}
<p class="text-danger"> <p class="text-danger">

View File

@ -6,9 +6,8 @@
<h1>Inventory</h1> <h1>Inventory</h1>
<nav> <nav>
<ol class="breadcrumb"> <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.devices.taglist')}}">Tag management</a></li>
<li class="breadcrumb-item active">Details tag</li> <li class="breadcrumb-item active">Tag details {{ tag.id }}</li>
<li class="breadcrumb-item active">{{ tag.id }}</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->

View File

@ -6,8 +6,7 @@
<h1>Inventory</h1> <h1>Inventory</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <li class="breadcrumb-item active">{{ page_title }}</li>
<li class="breadcrumb-item active">Tags Management</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->