def status(location_idx=None): if location_idx is None: locs = invelectronics.inventory_locations idents = [] for loc in locs: for line in loc.lines: if line.ident not in idents: idents.append(line.ident) stage = {'idents': idents, 'locs': locs, 'crumbroot': '/inventory', 'inv': invelectronics, 'breadcrumbs': [Crumb(name="Inventory", path=""), Crumb(name="Status", path="location/")], } return render_template('status.html', stage=stage, pagetitle="All Inventory Locations") else: loc = invelectronics.get_inventory_location(idx=location_idx) stage = {'loc': loc, 'crumbroot': '/inventory', 'breadcrumbs': [Crumb(name="Inventory", path=""), Crumb(name="Status", path="location/"), Crumb(name=loc.name, path="location/" + location_idx)], # noqa } return render_template('location_detail.html', stage=stage, pagetitle="Inventory Location " + loc.name)
def transforms(location_idx=None): if location_idx is None: locs = invelectronics.inventory_locations idents = gsymlib.gsymlib_idents stage = { 'idents': idents, 'locs': locs, 'crumbroot': '/inventory', 'inv': invelectronics, 'breadcrumbs': [ Crumb(name="Inventory", path=""), Crumb(name="Transforms", path="transform/") ], } return render_template('overview.html', stage=stage, pagetitle="All Inventory Transforms") else: loc = invelectronics.get_inventory_location(idx=location_idx) form = TransformUpdateForm(names=loc.tf.names) if form.validate_on_submit(): # This shouldn't actually be used anymore. The update_transform # AJAX handler should be called instead. if form.contextual.data in loc.tf.names: loc.tf.set_canonical_repr(form.contextual.data, form.canonical.data) loc.tf.set_status(form.contextual.data, form.status.data) loc.tf.update_on_disk() else: # TODO issue an alert here print( "Couldn't find the contextual representation in the transform" ) pass stage = { 'loc': loc, 'tf': loc.tf, 'gsymlib_idents': gsymlib.gsymlib_idents, 'form': form, 'crumbroot': '/inventory', 'breadcrumbs': [ Crumb(name="Inventory", path=""), Crumb(name="Transforms", path="transform/"), Crumb(name=loc.name, path="transform/" + location_idx) ], # noqa } return render_template('transform_detail.html', stage=stage, pagetitle="Inventory Transform " + loc.name)
def status(location_idx=None): if location_idx is None: locs = invelectronics.inventory_locations idents = [] for loc in locs: for line in loc.lines: if line.ident not in idents: idents.append(line.ident) stage = { 'idents': idents, 'locs': locs, 'crumbroot': '/inventory', 'inv': invelectronics, 'breadcrumbs': [ Crumb(name="Inventory", path=""), Crumb(name="Status", path="location/") ], } return render_template('status.html', stage=stage, pagetitle="All Inventory Locations") else: loc = invelectronics.get_inventory_location(idx=location_idx) stage = { 'loc': loc, 'crumbroot': '/inventory', 'breadcrumbs': [ Crumb(name="Inventory", path=""), Crumb(name="Status", path="location/"), Crumb(name=loc.name, path="location/" + location_idx) ], # noqa } return render_template('location_detail.html', stage=stage, pagetitle="Inventory Location " + loc.name)
def update_transform(location_idx): loc = invelectronics.get_inventory_location(idx=location_idx) form = TransformUpdateForm(names=loc.tf.names) if form.validate_on_submit(): contextual = form.contextual.data if contextual in loc.tf.names: canonical = form.canonical.data status = form.status.data loc.tf.set_canonical_repr(contextual, canonical) loc.tf.set_status(contextual, status) loc.tf.update_on_disk() return jsonify({ 'success': True, 'contextual': contextual, 'canonical': canonical, 'status': status, 'in_symlib': gsymlib.is_recognized(canonical) }) else: return jsonify({'success': False})
def transforms(location_idx=None): if location_idx is None: locs = invelectronics.inventory_locations idents = gsymlib.gsymlib_idents stage = {'idents': idents, 'locs': locs, 'crumbroot': '/inventory', 'inv': invelectronics, 'breadcrumbs': [Crumb(name="Inventory", path=""), Crumb(name="Transforms", path="transform/")], } return render_template('overview.html', stage=stage, pagetitle="All Inventory Transforms") else: loc = invelectronics.get_inventory_location(idx=location_idx) form = TransformUpdateForm(names=loc.tf.names) if form.validate_on_submit(): if form.contextual.data in loc.tf.names: loc.tf.set_canonical_repr(form.contextual.data, form.canonical.data) loc.tf.set_status(form.contextual.data, form.status.data) loc.tf.update_on_disk() else: # TODO issue an alert here print("Couldn't find the contextual representation in the transform") pass stage = {'loc': loc, 'tf': loc.tf, 'gsymlib_idents': gsymlib.gsymlib_idents, 'form': form, 'crumbroot': '/inventory', 'breadcrumbs': [Crumb(name="Inventory", path=""), Crumb(name="Transforms", path="transform/"), Crumb(name=loc.name, path="transform/" + location_idx)], # noqa } return render_template('transform_detail.html', stage=stage, pagetitle="Inventory Transform " + loc.name)