add tag list
This commit is contained in:
parent
062eed3d98
commit
4e43076c04
|
@ -4,6 +4,7 @@ from flask import Blueprint, url_for
|
|||
from flask_login import login_required, current_user
|
||||
|
||||
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
|
||||
|
||||
|
@ -95,6 +96,18 @@ class LotDeleteView(View):
|
|||
return flask.redirect(next_url)
|
||||
|
||||
|
||||
class TagListView(View):
|
||||
methods = ['GET']
|
||||
decorators = [login_required]
|
||||
template_name = 'inventory/tag_list.html'
|
||||
|
||||
def dispatch_request(self):
|
||||
tags = Tag.query.filter(
|
||||
Tag.owner_id == current_user.id)
|
||||
context = {'tags': tags,
|
||||
'lots': []}
|
||||
return flask.render_template(self.template_name, **context)
|
||||
|
||||
|
||||
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
|
||||
devices.add_url_rule('/lot/<string:id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
||||
|
@ -103,3 +116,4 @@ devices.add_url_rule('/lot/devices/del/', view_func=LotDeviceDeleteView.as_view(
|
|||
devices.add_url_rule('/lot/add/', view_func=LotView.as_view('lot_add'))
|
||||
devices.add_url_rule('/lot/<string:id>/del/', view_func=LotDeleteView.as_view('lot_del'))
|
||||
devices.add_url_rule('/lot/<string:id>/', view_func=LotView.as_view('lot_edit'))
|
||||
devices.add_url_rule('/tag/', view_func=TagListView.as_view('taglist'))
|
||||
|
|
|
@ -136,6 +136,10 @@ class Tag(Thing):
|
|||
def code(self) -> str:
|
||||
return hashcode.encode(self.internal_id)
|
||||
|
||||
@property
|
||||
def get_provider(self) -> str:
|
||||
return self.provider.to_text() if self.provider else ''
|
||||
|
||||
def delete(self):
|
||||
"""Deletes the tag.
|
||||
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
{% extends "ereuse_devicehub/base_site.html" %}
|
||||
{% block main %}
|
||||
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<div class="pagetitle">
|
||||
<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>
|
||||
</ol>
|
||||
</nav>
|
||||
</div><!-- End Page Title -->
|
||||
|
||||
<section class="section profile">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xl-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body pt-3">
|
||||
<!-- Bordered Tabs -->
|
||||
|
||||
<div class="btn-group dropdown ml-1">
|
||||
<a href="{{ url_for('inventory.devices.devicelist')}}" type="button" class="btn btn-primary">
|
||||
<i class="bi bi-plus"></i>
|
||||
Create Named Tag
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="btn-group dropdown ml-1" uib-dropdown="">
|
||||
<a href="{{ url_for('inventory.devices.devicelist')}}" type="button" class="btn btn-primary">
|
||||
<i class="bi bi-plus"></i>
|
||||
Create UnNamed Tag
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="tab-content pt-2">
|
||||
|
||||
<div class="tab-pane fade show active profile-overview" id="profile-overview">
|
||||
|
||||
<h5 class="card-title">Computers</h5>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Select all</th>
|
||||
<th scope="col">Code</th>
|
||||
<th scope="col">Type</th>
|
||||
<th scope="col">Provider</th>
|
||||
<th scope="col">Device</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for tag in tags %}
|
||||
<tr>
|
||||
<td><input type="checkbox" class="deviceSelect" data="{{ tag.id }}"/></td>
|
||||
<td>{{ tag.code }}</td>
|
||||
<td>{% if tag.provider %}Unnamed tag {% else %}Named tag{% endif %}</td>
|
||||
<td>{{ tag.get_provider }}</td>
|
||||
<td>{% if tag.device %}{{ tag.device.type }} {{ tag.device.manufacturer }} {{ tag.device.model }}{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div><!-- End Bordered Tabs -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- CDN -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest"></script>
|
||||
<!-- Custom Code -->
|
||||
<script>
|
||||
const table = new simpleDatatables.DataTable("table")
|
||||
</script>
|
||||
<script>
|
||||
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/jquery-3.6.0.min.js') }}"></script>
|
||||
{% endblock main %}
|
Reference in New Issue