Set page_title & fix breadcrumb
This commit is contained in:
parent
44a38d4dec
commit
c9a46128df
|
@ -7,8 +7,9 @@ from ereuse_devicehub.resources.lot.models import Lot
|
|||
from ereuse_devicehub.resources.tag.model import Tag
|
||||
from ereuse_devicehub.resources.device.models import Device
|
||||
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')
|
||||
|
||||
|
||||
|
@ -44,14 +45,14 @@ class DeviceListView(View):
|
|||
return flask.render_template(self.template_name, **context)
|
||||
|
||||
|
||||
class DeviceDetailsView(View):
|
||||
class DeviceDetailView(View):
|
||||
decorators = [login_required]
|
||||
template_name = 'inventory/device_details.html'
|
||||
|
||||
def dispatch_request(self, id):
|
||||
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
||||
device = Device.query.filter(
|
||||
Device.owner_id == current_user.id).filter(Device.devicehub_id == id).one()
|
||||
Device.owner_id == current_user.id).filter(Device.devicehub_id == id).one()
|
||||
|
||||
context = {'device': device,
|
||||
'lots': lots}
|
||||
|
@ -168,54 +169,61 @@ class TagListView(View):
|
|||
template_name = 'inventory/tag_list.html'
|
||||
|
||||
def dispatch_request(self):
|
||||
tags = Tag.query.filter(
|
||||
Tag.owner_id == current_user.id)
|
||||
context = {'tags': tags,
|
||||
'lots': []}
|
||||
tags = Tag.query.filter(Tag.owner_id == current_user.id)
|
||||
context = {
|
||||
'lots': [],
|
||||
'tags': tags,
|
||||
'page_title': 'Tags Management',
|
||||
}
|
||||
return flask.render_template(self.template_name, **context)
|
||||
|
||||
|
||||
class TagAddView(View):
|
||||
methods = ['GET', 'POST']
|
||||
decorators = [login_required]
|
||||
template_name = 'inventory/tag.html'
|
||||
template_name = 'inventory/tag_create.html'
|
||||
|
||||
def dispatch_request(self):
|
||||
context = {'page_title': 'New Tag'}
|
||||
form = TagForm()
|
||||
if form.validate_on_submit():
|
||||
form.save()
|
||||
next_url = url_for('inventory.devices.taglist')
|
||||
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):
|
||||
methods = ['GET', 'POST']
|
||||
decorators = [login_required]
|
||||
template_name = 'inventory/tagUnnamed.html'
|
||||
template_name = 'inventory/tag_create_unnamed.html'
|
||||
|
||||
def dispatch_request(self):
|
||||
context = {'page_title': 'New Unnamed Tag'}
|
||||
form = TagUnnamedForm()
|
||||
if form.validate_on_submit():
|
||||
form.save()
|
||||
next_url = url_for('inventory.devices.taglist')
|
||||
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]
|
||||
template_name = 'inventory/tag_details.html'
|
||||
template_name = 'inventory/tag_detail.html'
|
||||
|
||||
def dispatch_request(self, id):
|
||||
lots = Lot.query.filter(Lot.owner_id == current_user.id)
|
||||
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,
|
||||
'lots': lots}
|
||||
context = {
|
||||
'lots': lots,
|
||||
'tag': tag,
|
||||
'page_title': '{} Tag'.format(tag.code),
|
||||
}
|
||||
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/<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/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'))
|
||||
|
@ -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/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/<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/<int:id>/del/', view_func=TagDeviceDeleteView.as_view('tag_devices_del'))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "ereuse_devicehub/base.html" %}
|
||||
{% block page_title %}{{ page_title }}{% endblock %}
|
||||
{% block body %}
|
||||
<!-- ======= Header ======= -->
|
||||
<header id="header" class="header fixed-top d-flex align-items-center">
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<h1>{{ title }}</h1>
|
||||
<nav>
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li>
|
||||
<li class="breadcrumb-item">Tag</li>
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
|
||||
<li class="breadcrumb-item">{{ page_title }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div><!-- End Page Title -->
|
|
@ -5,8 +5,8 @@
|
|||
<h1>{{ title }}</h1>
|
||||
<nav>
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li>
|
||||
<li class="breadcrumb-item">Tag</li>
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
|
||||
<li class="breadcrumb-item">{{ page_title }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div><!-- End Page Title -->
|
||||
|
@ -19,7 +19,7 @@
|
|||
<div class="card-body">
|
||||
|
||||
<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>
|
||||
{% if form.form_errors %}
|
||||
<p class="text-danger">
|
|
@ -6,9 +6,8 @@
|
|||
<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 active">Details tag</li>
|
||||
<li class="breadcrumb-item active">{{ tag.id }}</li>
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.taglist')}}">Tag management</a></li>
|
||||
<li class="breadcrumb-item active">Tag details {{ tag.id }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div><!-- End Page Title -->
|
|
@ -6,8 +6,7 @@
|
|||
<h1>Inventory</h1>
|
||||
<nav>
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li>
|
||||
<li class="breadcrumb-item active">Tags Management</li>
|
||||
<li class="breadcrumb-item active">{{ page_title }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div><!-- End Page Title -->
|
||||
|
|
Reference in New Issue