diff --git a/ereuse_devicehub/devicehub.py b/ereuse_devicehub/devicehub.py index f2e30ddc..1051c951 100644 --- a/ereuse_devicehub/devicehub.py +++ b/ereuse_devicehub/devicehub.py @@ -7,8 +7,10 @@ import click import click_spinner import ereuse_utils.cli from ereuse_utils.session import DevicehubClient -from flask.globals import _app_ctx_stack, g +from flask import _app_ctx_stack, g +from flask_login import LoginManager, current_user from flask_sqlalchemy import SQLAlchemy +from flask_wtf.csrf import CSRFProtect from teal.db import SchemaSQLAlchemy from teal.teal import Teal @@ -19,11 +21,8 @@ from ereuse_devicehub.db import db from ereuse_devicehub.dummy.dummy import Dummy from ereuse_devicehub.resources.device.search import DeviceSearch from ereuse_devicehub.resources.inventory import Inventory, InventoryDef -from ereuse_devicehub.templating import Environment - - -from flask_login import LoginManager from ereuse_devicehub.resources.user.models import User +from ereuse_devicehub.templating import Environment class Devicehub(Teal): @@ -165,6 +164,9 @@ class Devicehub(Teal): inv = g.inventory = Inventory.current # type: Inventory g.tag_provider = DevicehubClient(base_url=inv.tag_provider, token=DevicehubClient.encode_token(inv.tag_token)) + # NOTE: models init methods expects that current user is + # available on g.user (e.g. to initialize object owner) + g.user = current_user def create_client(self, email='user@dhub.com', password='1234'): client = UserClient(self, email, password, response_wrapper=self.response_class) diff --git a/ereuse_devicehub/inventory/__init__.py b/ereuse_devicehub/inventory/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py new file mode 100644 index 00000000..16b93452 --- /dev/null +++ b/ereuse_devicehub/inventory/forms.py @@ -0,0 +1,375 @@ +import json +from flask_wtf import FlaskForm +from wtforms import StringField, validators, MultipleFileField, FloatField, IntegerField +from flask import g, request +from sqlalchemy.util import OrderedSet +from json.decoder import JSONDecodeError + +from ereuse_devicehub.db import db +from ereuse_devicehub.resources.device.models import Device, Computer, Smartphone, Cellphone, \ + Tablet, Monitor, Mouse, Keyboard, \ + MemoryCardReader, SAI +from ereuse_devicehub.resources.action.models import RateComputer, Snapshot, VisualTest +from ereuse_devicehub.resources.action.schemas import Snapshot as SnapshotSchema +from ereuse_devicehub.resources.lot.models import Lot +from ereuse_devicehub.resources.enums import SnapshotSoftware, Severity +from ereuse_devicehub.resources.user.exceptions import InsufficientPermission +from ereuse_devicehub.resources.action.rate.v1_0 import CannotRate +from ereuse_devicehub.resources.device.sync import Sync +from ereuse_devicehub.resources.action.views.snapshot import save_json, move_json + + +class LotDeviceForm(FlaskForm): + lot = StringField(u'Lot', [validators.UUID()]) + devices = StringField(u'Devices', [validators.length(min=1)]) + + def validate(self, extra_validators=None): + is_valid = super().validate(extra_validators) + + if not is_valid: + return False + + self._lot = Lot.query.filter(Lot.id == self.lot.data).filter( + Lot.owner_id == g.user.id).one() + + devices = set(self.devices.data.split(",")) + self._devices = Device.query.filter(Device.id.in_(devices)).filter( + Device.owner_id == g.user.id).distinct().all() + + return bool(self._devices) + + def save(self): + self._lot.devices.update(self._devices) + db.session.add(self._lot) + db.session.commit() + + def remove(self): + self._lot.devices.difference_update(self._devices) + db.session.add(self._lot) + db.session.commit() + + +class LotForm(FlaskForm): + name = StringField(u'Name', [validators.length(min=1)]) + + def __init__(self, *args, **kwargs): + self.id = kwargs.pop('id', None) + self.instance = None + if self.id: + self.instance = Lot.query.filter(Lot.id == self.id).filter( + Lot.owner_id == g.user.id).one() + super().__init__(*args, **kwargs) + if self.instance and not self.name.data: + self.name.data = self.instance.name + + def save(self): + if not self.id: + self.instance = Lot(name=self.name.data) + + self.populate_obj(self.instance) + + if not self.id: + self.id = self.instance.id + db.session.add(self.instance) + db.session.commit() + return self.id + + db.session.commit() + return self.id + + def remove(self): + if self.instance and not self.instance.devices: + self.instance.delete() + db.session.commit() + return self.instance + + +class UploadSnapshotForm(FlaskForm): + snapshot = MultipleFileField(u'Select a Snapshot File', [validators.DataRequired()]) + + def validate(self, extra_validators=None): + is_valid = super().validate(extra_validators) + + if not is_valid: + return False + + data = request.files.getlist(self.snapshot.name) + if not data: + return False + self.snapshots = [] + self.result = {} + for d in data: + filename = d.filename + self.result[filename] = 'Not processed' + d = d.stream.read() + if not d: + self.result[filename] = 'Error this snapshot is empty' + continue + + try: + d_json = json.loads(d) + except JSONDecodeError: + self.result[filename] = 'Error this snapshot is not a json' + continue + + uuid_snapshot = d_json.get('uuid') + if Snapshot.query.filter(Snapshot.uuid == uuid_snapshot).all(): + self.result[filename] = 'Error this snapshot exist' + continue + + self.snapshots.append((filename, d_json)) + + if not self.snapshots: + return False + + return True + + def save(self): + if any([x == 'Error' for x in self.result.values()]): + return + # result = [] + self.sync = Sync() + schema = SnapshotSchema() + # self.tmp_snapshots = app.config['TMP_SNAPSHOTS'] + # TODO @cayop get correct var config + self.tmp_snapshots = '/tmp/' + for filename, snapshot_json in self.snapshots: + path_snapshot = save_json(snapshot_json, self.tmp_snapshots, g.user.email) + snapshot_json.pop('debug', None) + snapshot_json = schema.load(snapshot_json) + response = self.build(snapshot_json) + + if hasattr(response, 'type'): + self.result[filename] = 'Ok' + else: + self.result[filename] = 'Error' + + move_json(self.tmp_snapshots, path_snapshot, g.user.email) + + db.session.commit() + return response + + def build(self, snapshot_json): + # this is a copy adaptated from ereuse_devicehub.resources.action.views.snapshot + device = snapshot_json.pop('device') # type: Computer + components = None + if snapshot_json['software'] == (SnapshotSoftware.Workbench or SnapshotSoftware.WorkbenchAndroid): + components = snapshot_json.pop('components', None) # type: List[Component] + if isinstance(device, Computer) and device.hid: + device.add_mac_to_hid(components_snap=components) + snapshot = Snapshot(**snapshot_json) + + # Remove new actions from devices so they don't interfere with sync + actions_device = set(e for e in device.actions_one) + device.actions_one.clear() + if components: + actions_components = tuple(set(e for e in c.actions_one) for c in components) + for component in components: + component.actions_one.clear() + + assert not device.actions_one + assert all(not c.actions_one for c in components) if components else True + db_device, remove_actions = self.sync.run(device, components) + + del device # Do not use device anymore + snapshot.device = db_device + snapshot.actions |= remove_actions | actions_device # Set actions to snapshot + # commit will change the order of the components by what + # the DB wants. Let's get a copy of the list so we preserve order + ordered_components = OrderedSet(x for x in snapshot.components) + + # Add the new actions to the db-existing devices and components + db_device.actions_one |= actions_device + if components: + for component, actions in zip(ordered_components, actions_components): + component.actions_one |= actions + snapshot.actions |= actions + + if snapshot.software == SnapshotSoftware.Workbench: + # Check ownership of (non-component) device to from current.user + if db_device.owner_id != g.user.id: + raise InsufficientPermission() + # Compute ratings + try: + rate_computer, price = RateComputer.compute(db_device) + except CannotRate: + pass + else: + snapshot.actions.add(rate_computer) + if price: + snapshot.actions.add(price) + elif snapshot.software == SnapshotSoftware.WorkbenchAndroid: + pass # TODO try except to compute RateMobile + # Check if HID is null and add Severity:Warning to Snapshot + if snapshot.device.hid is None: + snapshot.severity = Severity.Warning + + db.session.add(snapshot) + return snapshot + + +class NewDeviceForm(FlaskForm): + type = StringField(u'Type', [validators.DataRequired()]) + label = StringField(u'Label') + serial_number = StringField(u'Seria Number', [validators.DataRequired()]) + model = StringField(u'Model', [validators.DataRequired()]) + manufacturer = StringField(u'Manufacturer', [validators.DataRequired()]) + appearance = StringField(u'Appearance', [validators.Optional()]) + functionality = StringField(u'Functionality', [validators.Optional()]) + brand = StringField(u'Brand') + generation = IntegerField(u'Generation') + version = StringField(u'Version') + weight = FloatField(u'Weight', [validators.DataRequired()]) + width = FloatField(u'Width', [validators.DataRequired()]) + height = FloatField(u'Height', [validators.DataRequired()]) + depth = FloatField(u'Depth', [validators.DataRequired()]) + variant = StringField(u'Variant', [validators.Optional()]) + sku = StringField(u'SKU', [validators.Optional()]) + image = StringField(u'Image', [validators.Optional(), validators.URL()]) + imei = IntegerField(u'IMEI', [validators.Optional()]) + meid = StringField(u'MEID', [validators.Optional()]) + resolution = IntegerField(u'Resolution width', [validators.Optional()]) + screen = FloatField(u'Screen size', [validators.Optional()]) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.devices = {"Smartphone": Smartphone, + "Tablet": Tablet, + "Cellphone": Cellphone, + "Monitor": Monitor, + "Mouse": Mouse, + "Keyboard": Keyboard, + "SAI": SAI, + "MemoryCardReader": MemoryCardReader} + + if not self.generation.data: + self.generation.data = 1 + + if not self.weight.data: + self.weight.data = 0.1 + + if not self.height.data: + self.height.data = 0.1 + + if not self.width.data: + self.width.data = 0.1 + + if not self.depth.data: + self.depth.data = 0.1 + + def validate(self, extra_validators=None): + error = ["Not a correct value"] + is_valid = super().validate(extra_validators) + + if self.generation.data < 1: + self.generation.errors = error + is_valid = False + + if self.weight.data < 0.1: + self.weight.errors = error + is_valid = False + + if self.height.data < 0.1: + self.height.errors = error + is_valid = False + + if self.width.data < 0.1: + self.width.errors = error + is_valid = False + + if self.depth.data < 0.1: + self.depth.errors = error + is_valid = False + + if self.imei.data: + if not 13 < len(str(self.imei.data)) < 17: + self.imei.errors = error + is_valid = False + + if self.meid.data: + meid = self.meid.data + if not 13 < len(meid) < 17: + is_valid = False + try: + int(meid, 16) + except ValueError: + self.meid.errors = error + is_valid = False + + if not is_valid: + return False + + if self.image.data == '': + self.image.data = None + if self.manufacturer.data: + self.manufacturer.data = self.manufacturer.data.lower() + if self.model.data: + self.model.data = self.model.data.lower() + if self.serial_number.data: + self.serial_number.data = self.serial_number.data.lower() + + return True + + def save(self): + + json_snapshot = { + 'type': 'Snapshot', + 'software': 'Web', + 'version': '11.0', + 'device': { + 'type': self.type.data, + 'model': self.model.data, + 'manufacturer': self.manufacturer.data, + 'serialNumber': self.serial_number.data, + 'brand': self.brand.data, + 'version': self.version.data, + 'generation': self.generation.data, + 'sku': self.sku.data, + 'weight': self.weight.data, + 'width': self.width.data, + 'height': self.height.data, + 'depth': self.depth.data, + 'variant': self.variant.data, + 'image': self.image.data + } + } + + if self.appearance.data or self.functionality.data: + json_snapshot['device']['actions'] = [{ + 'type': 'VisualTest', + 'appearanceRange': self.appearance.data, + 'functionalityRange': self.functionality.data + }] + + upload_form = UploadSnapshotForm() + upload_form.sync = Sync() + + schema = SnapshotSchema() + self.tmp_snapshots = '/tmp/' + path_snapshot = save_json(json_snapshot, self.tmp_snapshots, g.user.email) + snapshot_json = schema.load(json_snapshot) + + if self.type.data == 'Monitor': + snapshot_json['device'].resolution_width = self.resolution.data + snapshot_json['device'].size = self.screen.data + + if self.type.data in ['Smartphone', 'Tablet', 'Cellphone']: + snapshot_json['device'].imei = self.imei.data + snapshot_json['device'].meid = self.meid.data + + snapshot = upload_form.build(snapshot_json) + + move_json(self.tmp_snapshots, path_snapshot, g.user.email) + if self.type.data == 'Monitor': + snapshot.device.resolution = self.resolution.data + snapshot.device.screen = self.screen.data + + db.session.commit() + return snapshot + + +class NewActionForm(FlaskForm): + name = StringField(u'Name') + date = StringField(u'Date') + severity = StringField(u'Severity') + description = StringField(u'Description') diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py new file mode 100644 index 00000000..67d65126 --- /dev/null +++ b/ereuse_devicehub/inventory/views.py @@ -0,0 +1,167 @@ +import flask +from flask.views import View +from flask import Blueprint, url_for, request +from flask_login import login_required, current_user + +from ereuse_devicehub.resources.lot.models import Lot +from ereuse_devicehub.resources.device.models import Device +from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, UploadSnapshotForm, NewDeviceForm + +devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory') + + +class DeviceListView(View): + decorators = [login_required] + template_name = 'inventory/device_list.html' + + def dispatch_request(self, lot_id=None): + # TODO @cayop adding filter + # https://github.com/eReuse/devicehub-teal/blob/testing/ereuse_devicehub/resources/device/views.py#L56 + filter_types = ['Desktop', 'Laptop', 'Server'] + lots = Lot.query.filter(Lot.owner_id == current_user.id) + lot = None + if lot_id: + lot = lots.filter(Lot.id == lot_id).one() + devices = [dev for dev in lot.devices if dev.type in filter_types] + devices = sorted(devices, key=lambda x: x.updated, reverse=True) + else: + devices = Device.query.filter( + Device.owner_id == current_user.id).filter( + Device.type.in_(filter_types)).filter(Device.lots == None).order_by( + Device.updated.desc()) + + context = {'devices': devices, + 'lots': lots, + 'form_lot_device': LotDeviceForm(), + 'lot': lot} + return flask.render_template(self.template_name, **context) + + +class DeviceDetailsView(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() + + context = {'device': device, + 'lots': lots} + return flask.render_template(self.template_name, **context) + + +class LotDeviceAddView(View): + methods = ['POST'] + decorators = [login_required] + template_name = 'inventory/device_list.html' + + def dispatch_request(self): + form = LotDeviceForm() + if form.validate_on_submit(): + form.save() + + next_url = request.referrer or url_for('inventory.devices.devicelist') + return flask.redirect(next_url) + + +class LotDeviceDeleteView(View): + methods = ['POST'] + decorators = [login_required] + template_name = 'inventory/device_list.html' + + def dispatch_request(self): + form = LotDeviceForm() + if form.validate_on_submit(): + form.remove() + + next_url = request.referrer or url_for('inventory.devices.devicelist') + return flask.redirect(next_url) + + +class LotCreateView(View): + methods = ['GET', 'POST'] + decorators = [login_required] + template_name = 'inventory/lot.html' + title = "Add a new lot" + + def dispatch_request(self): + form = LotForm() + if form.validate_on_submit(): + form.save() + next_url = url_for('inventory.devices.lotdevicelist', lot_id=form.id) + return flask.redirect(next_url) + + lots = Lot.query.filter(Lot.owner_id == current_user.id) + return flask.render_template(self.template_name, form=form, title=self.title, lots=lots) + + +class LotUpdateView(View): + methods = ['GET', 'POST'] + decorators = [login_required] + template_name = 'inventory/lot.html' + title = "Edit a new lot" + + def dispatch_request(self, id): + form = LotForm(id=id) + if form.validate_on_submit(): + form.save() + next_url = url_for('inventory.devices.lotdevicelist', lot_id=id) + return flask.redirect(next_url) + + lots = Lot.query.filter(Lot.owner_id == current_user.id) + return flask.render_template(self.template_name, form=form, title=self.title, lots=lots) + + +class LotDeleteView(View): + methods = ['GET'] + decorators = [login_required] + template_name = 'inventory/device_list.html' + + def dispatch_request(self, id): + form = LotForm(id=id) + form.remove() + next_url = url_for('inventory.devices.devicelist') + return flask.redirect(next_url) + + +class UploadSnapshotView(View): + methods = ['GET', 'POST'] + decorators = [login_required] + template_name = 'inventory/upload_snapshot.html' + + def dispatch_request(self): + lots = Lot.query.filter(Lot.owner_id == current_user.id).all() + form = UploadSnapshotForm() + if form.validate_on_submit(): + form.save() + + return flask.render_template(self.template_name, form=form, lots=lots) + + +class CreateDeviceView(View): + methods = ['GET', 'POST'] + decorators = [login_required] + template_name = 'inventory/create_device.html' + + def dispatch_request(self): + lots = Lot.query.filter(Lot.owner_id == current_user.id).all() + form = NewDeviceForm() + if form.validate_on_submit(): + form.save() + next_url = url_for('inventory.devices.devicelist') + return flask.redirect(next_url) + + return flask.render_template(self.template_name, form=form, lots=lots) + + +devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist')) +devices.add_url_rule('/device//', view_func=DeviceDetailsView.as_view('device_details')) +devices.add_url_rule('/lot//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')) +devices.add_url_rule('/lot/add/', view_func=LotCreateView.as_view('lot_add')) +devices.add_url_rule('/lot//del/', view_func=LotDeleteView.as_view('lot_del')) +devices.add_url_rule('/lot//', view_func=LotUpdateView.as_view('lot_edit')) +devices.add_url_rule('/upload-snapshot/', view_func=UploadSnapshotView.as_view('upload_snapshot')) +devices.add_url_rule('/device/add/', view_func=CreateDeviceView.as_view('device_add')) diff --git a/ereuse_devicehub/resources/lot/models.py b/ereuse_devicehub/resources/lot/models.py index 9699c969..88c68626 100644 --- a/ereuse_devicehub/resources/lot/models.py +++ b/ereuse_devicehub/resources/lot/models.py @@ -5,6 +5,7 @@ from typing import Union from boltons import urlutils from citext import CIText from flask import g +from flask_login import current_user from sqlalchemy import TEXT from sqlalchemy.dialects.postgresql import UUID from sqlalchemy_utils import LtreeType @@ -101,7 +102,15 @@ class Lot(Thing): @property def is_temporary(self): - return False if self.trade else True + return not bool(self.trade) + + @property + def is_incoming(self): + return bool(self.trade and self.trade.user_to == current_user) + + @property + def is_outgoing(self): + return bool(self.trade and self.trade.user_from == current_user) @classmethod def descendantsq(cls, id): diff --git a/ereuse_devicehub/static/js/create_device.js b/ereuse_devicehub/static/js/create_device.js new file mode 100644 index 00000000..1c9e0655 --- /dev/null +++ b/ereuse_devicehub/static/js/create_device.js @@ -0,0 +1,23 @@ +$(document).ready(function() { + $("#type").on("change", deviceInputs); + deviceInputs(); +}) + +function deviceInputs() { + if ($("#type").val() == 'Monitor') { + $("#screen").show(); + $("#resolution").show(); + $("#imei").hide(); + $("#meid").hide(); + } else if (['Smartphone', 'Cellphone', 'Tablet'].includes($("#type").val())) { + $("#screen").hide(); + $("#resolution").hide(); + $("#imei").show(); + $("#meid").show(); + } else { + $("#screen").hide(); + $("#resolution").hide(); + $("#imei").hide(); + $("#meid").hide(); + } +} diff --git a/ereuse_devicehub/static/js/jquery-3.6.0.min.js b/ereuse_devicehub/static/js/jquery-3.6.0.min.js new file mode 100644 index 00000000..c4c6022f --- /dev/null +++ b/ereuse_devicehub/static/js/jquery-3.6.0.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0 @@ -120,39 +119,37 @@ Outgoing Lots diff --git a/ereuse_devicehub/templates/inventory/actions.html b/ereuse_devicehub/templates/inventory/actions.html new file mode 100644 index 00000000..2800c921 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/actions.html @@ -0,0 +1,28 @@ + diff --git a/ereuse_devicehub/templates/inventory/addDeviceslot.html b/ereuse_devicehub/templates/inventory/addDeviceslot.html new file mode 100644 index 00000000..e05f665f --- /dev/null +++ b/ereuse_devicehub/templates/inventory/addDeviceslot.html @@ -0,0 +1,33 @@ + diff --git a/ereuse_devicehub/templates/inventory/create_device.html b/ereuse_devicehub/templates/inventory/create_device.html new file mode 100644 index 00000000..5a0380ca --- /dev/null +++ b/ereuse_devicehub/templates/inventory/create_device.html @@ -0,0 +1,391 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + +
+

{{ title }}

+ +
+ +
+
+
+ +
+
+ +
+
New Device
+ {% if form.form_errors %} +

+ {% for error in form.form_errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ {{ form.csrf_token }} + +
+
+ + + Type of devices + {% if form.type.errors %} +

+ {% for error in form.type.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.label(class_="form-control") }} + Label that you want link to this device + {% if form.label.errors %} +

+ {% for error in form.label.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.serial_number(class_="form-control") }} + Serial number of this device + {% if form.serial_number.errors %} +

+ {% for error in form.serial_number.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.model(class_="form-control") }} + Name of model + {% if form.model.errors %} +

+ {% for error in form.model.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.manufacturer(class_="form-control") }} + Name of manufacturer + {% if form.manufacturer.errors %} +

+ {% for error in form.manufacturer.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ Rate the imperfections that affect the device aesthetically, but not its use. + {% if form.appearance.errors %} +

+ {% for error in form.appearance.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ It qualifies the defects of a device that affect its use. + {% if form.functionality.errors %} +

+ {% for error in form.functionality.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.brand(class_="form-control") }} + A naming for consumers. This field can represent several models, so it can be ambiguous, and it is not used to identify the product. + {% if form.brand.errors %} +

+ {% for error in form.brand.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.generation(class_="form-control") }} + The generation of the device. + {% if form.generation.errors %} +

+ {% for error in form.generation.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.version(class_="form-control") }} + The version code o fthis device, like 'v1' or 'A001'. + {% if form.version.errors %} +

+ {% for error in form.version.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.weight(class_="form-control") }} + The weight of the device in Kg. + {% if form.weight.errors %} +

+ {% for error in form.weight.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.width(class_="form-control") }} + The width of the device in meters. + {% if form.width.errors %} +

+ {% for error in form.width.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.height(class_="form-control") }} + The height of the device in meters. + {% if form.height.errors %} +

+ {% for error in form.height.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.depth(class_="form-control") }} + The depth of the device in meters. + {% if form.depth.errors %} +

+ {% for error in form.depth.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.variant(class_="form-control") }} + A variant or sub-model of the device. + {% if form.variant.errors %} +

+ {% for error in form.variant.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.sku(class_="form-control") }} + The Stock Keeping Unit (SKU), i.e. a merchant-specific identifier for a product or service. + {% if form.sku.errors %} +

+ {% for error in form.sku.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.image(class_="form-control") }} + An URL containing an image of the device. + {% if form.image.errors %} +

+ {% for error in form.image.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.imei(class_="form-control") }} + A number from 14 to 16 digits. + {% if form.imei.errors %} +

+ {% for error in form.imei.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.meid(class_="form-control") }} + 14 hexadecimal digits. + {% if form.meid.errors %} +

+ {% for error in form.meid.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.resolution(class_="form-control") }} + The resolution width of the screen. + {% if form.resolution.errors %} +

+ {% for error in form.resolution.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ + {{ form.screen(class_="form-control") }} + The size of the screen. + {% if form.screen.errors %} +

+ {% for error in form.screen.errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ +
+ Cancel + +
+
+ +
+ +
+ +
+ +
+
+
+
+ + +{% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/device_details.html b/ereuse_devicehub/templates/inventory/device_details.html new file mode 100644 index 00000000..f6ebd522 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/device_details.html @@ -0,0 +1,150 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + + +
+

Inventory

+ +
+ +
+
+ +
+ +
+
+

{{ device.devicehub_id }}

+ + +
+ +
+
Type Details
+ +
+
Type
+
{{ device.type }}
+
+ +
+
Manufacturer
+
{{ device.manufacturer }}
+
+ +
+
Model
+
{{ device.model }}
+
+ +
+
Serial Number
+
{{ device.serial_number }}
+
+
+ +
+
Status Details
+
+
Physical States
+
{{ device.physical or '' }}
+
+
+
Trading States
+
{{ device.last_action_trading or ''}}
+
+
+
Usage States
+
{{ device.usage or '' }}
+
+
+ +
+
Rate Details
+
+
Rating
+
{{ device.rate or '' }}
+
+
+
Processor
+
{{ device.rate.processor or '' }}
+
+
+
RAM
+
{{ device.rate.ram or '' }}
+
+
+
Data storage
+
{{ device.rate.data_storage or '' }}
+
+
+ +
+
Traceability log Details
+
+ {% for action in device.actions %} +
+ {{ action.type }} {{ action.severity }} + {{ action.created.strftime('%H:%M %d-%m-%Y') }} +
+ {% endfor %} +
+
+ +
+
Components Details
+
+ {% for component in device.components|sort(attribute='type') %} +
+
+
{{ component.type }}
+ {{ component.created.strftime('%H:%M %d-%m-%Y') }} +
+

+ {{ component.manufacturer }}
+ {{ component.model }}
+

+ + {% if component.type in ['RamModule', 'HardDrive', 'SolidStateDrive'] %} + {{ component.size }}MB + {% endif %} + +
+ {% endfor %} +
+
+ +
+
+
+
+
+{% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/device_list.html b/ereuse_devicehub/templates/inventory/device_list.html new file mode 100644 index 00000000..c281f89a --- /dev/null +++ b/ereuse_devicehub/templates/inventory/device_list.html @@ -0,0 +1,281 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + + +
+

Inventory

+ +
+ +
+
+ +
+ + {% if lot %} +
+
+ + + +
+
+ {% endif %} +
+
+ + + + + + + + + + + + +
+ +
+ +
Computers
+ + + + + + + + + + + + + {% for dev in devices %} + + + + + + + + + {% endfor %} + +
Select allTitleDHIDTagsStatusUpdate
{{ dev.type }} {{ dev.manufacturer }} {{ dev.model }}{{ dev.devicehub_id }} + {% for t in dev.tags | sort(attribute="id") %} + {{ t.id }}{% if not loop.last %},{% endif %} + {% endfor %} + {% if dev.status %}{{ dev.status }}{% endif %}{{ dev.updated.strftime('%H:%M %d-%m-%Y') }}
+ +
+ +
+
+ +
+
+
+{% include "inventory/addDeviceslot.html" %} +{% include "inventory/removeDeviceslot.html" %} +{% include "inventory/removelot.html" %} +{% include "inventory/actions.html" %} + + + + + + + + +{% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/lot.html b/ereuse_devicehub/templates/inventory/lot.html new file mode 100644 index 00000000..eaa3d350 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/lot.html @@ -0,0 +1,60 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + +
+

{{ title }}

+ +
+ +
+
+
+ +
+
+ +
+
{{ title }}
+

Please enter a name of the lot.

+ {% if form.form_errors %} +

+ {% for error in form.form_errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ {{ form.csrf_token }} + +
+ +
+ +
Please enter a name of the lot.
+
+
+ +
+ Cancel + +
+
+ +
+ +
+ +
+ +
+
+
+
+{% endblock main %} diff --git a/ereuse_devicehub/templates/inventory/removeDeviceslot.html b/ereuse_devicehub/templates/inventory/removeDeviceslot.html new file mode 100644 index 00000000..81ba6be6 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/removeDeviceslot.html @@ -0,0 +1,32 @@ + diff --git a/ereuse_devicehub/templates/inventory/removelot.html b/ereuse_devicehub/templates/inventory/removelot.html new file mode 100644 index 00000000..125d97d3 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/removelot.html @@ -0,0 +1,23 @@ + diff --git a/ereuse_devicehub/templates/inventory/upload_snapshot.html b/ereuse_devicehub/templates/inventory/upload_snapshot.html new file mode 100644 index 00000000..a29f3e46 --- /dev/null +++ b/ereuse_devicehub/templates/inventory/upload_snapshot.html @@ -0,0 +1,73 @@ +{% extends "ereuse_devicehub/base_site.html" %} +{% block main %} + +
+

{{ title }}

+ +
+ +
+
+
+ +
+
+ +
+
Upload Snapshot
+

Please select a file snapshot.

+ {% if form.form_errors %} +

+ {% for error in form.form_errors %} + {{ error }}
+ {% endfor %} +

+ {% endif %} +
+ +
+ {{ form.csrf_token }} + +
+ +
+ {{ form.snapshot }} +
You can select multiple files Snapshots JSON.
+
+ {% if form.result %} + {% for filename, result in form.result.items() %} + {% if result == 'Ok' %} +

+ {{ filename }}: {{ result }}
+

+ {% else %} +

+ {{ filename }}: {{ result }}
+

+ {% endif %} + {% endfor %} + {% endif %} +
+ +
+ Cancel + +
+
+ +
+ +
+ +
+ +
+
+
+
+{% endblock main %}