adding rendering list

This commit is contained in:
Cayo Puigdefabregas 2021-12-28 13:55:56 +01:00
parent 9e042125a3
commit c8be2bb640
3 changed files with 29 additions and 36 deletions

View file

@ -1,22 +1,27 @@
import flask
from flask import Blueprint
from flask.views import View
from flask_login import login_required, login_user
from flask_login import login_required, current_user
from ereuse_devicehub.forms import LoginForm
from ereuse_devicehub.resources.user.models import User
from ereuse_devicehub.resources.device.models import Device
from ereuse_devicehub.utils import is_safe_url
devices = Blueprint('devices', __name__)
devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory')
class DeviceListView(View):
# decorators = [login_required]
decorators = [login_required]
template_name = 'inventory/device_list.html'
def dispatch_request(self):
context = {}
# import pdb; pdb.set_trace()
filter_types = ['Desktop', 'Laptop', 'Server']
devices = Device.query.filter(
Device.owner_id==current_user.id).filter(
Device.type.in_(filter_types))
context = {'devices': devices}
return flask.render_template(self.template_name, **context)
devices.add_url_rule('/inventory/device/list/', view_func=DeviceListView.as_view('devicelist'))
devices.add_url_rule('/device/list/', view_func=DeviceListView.as_view('devicelist'))

View file

@ -242,7 +242,7 @@
</li><!-- End Dashboard Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="#">
<a class="nav-link collapsed" href="{{ url_for('inventory.devices.devicelist') }}">
<i class="bi-menu-button-wide"></i>
<span>Unassigned devices</span>
</a>

View file

@ -46,39 +46,27 @@
<h5 class="card-title">Computers</h5>
<div class="row">
<div class="col-lg-3 col-md-4 label ">Full Name</div>
<div class="col-lg-9 col-md-8">Kevin Anderson</div>
<div class="col">Title</div>
<div class="col-1">DHID</div>
<div class="col">Tags</div>
<div class="col-1">Status</div>
<div class="col">Update</div>
</div>
{% for dev in devices %}
<div class="row">
<div class="col-lg-3 col-md-4 label">Company</div>
<div class="col-lg-9 col-md-8">Lueilwitz, Wisoky and Leuschke</div>
<div class="col">{{ dev.type }} {{ dev.manufacturer }} {{ dev.model }}</div>
<div class="col-1">{{ dev.devicehub_id }}</div>
<div class="col">
{% for t in dev.tags %}
{{ t.code }}
{% endfor %}
</div>
<div class="col-1">{% if dev.status %}{{ dev.status }}{% endif %}</div>
<div class="col">{{ dev.updated.strftime('%H:%M %d-%m-%Y') }}</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Job</div>
<div class="col-lg-9 col-md-8">Web Designer</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Country</div>
<div class="col-lg-9 col-md-8">USA</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Address</div>
<div class="col-lg-9 col-md-8">A108 Adam Street, New York, NY 535022</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Phone</div>
<div class="col-lg-9 col-md-8">(436) 486-3538 x29071</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 label">Email</div>
<div class="col-lg-9 col-md-8">k.anderson@example.com</div>
</div>
{% endfor %}
</div>