precommit
This commit is contained in:
parent
71926f01c0
commit
d20bd63cae
|
@ -51,43 +51,29 @@ from ereuse_devicehub.resources.tradedocument.models import TradeDocument
|
||||||
from ereuse_devicehub.resources.user.exceptions import InsufficientPermission
|
from ereuse_devicehub.resources.user.exceptions import InsufficientPermission
|
||||||
from ereuse_devicehub.resources.user.models import User
|
from ereuse_devicehub.resources.user.models import User
|
||||||
|
|
||||||
DEVICES = [
|
DEVICES = {
|
||||||
("All", "All"),
|
"All": ["All"],
|
||||||
("Desktop", "Desktop"),
|
"Computer": [
|
||||||
("Laptop", "Laptop"),
|
"Desktop",
|
||||||
("Server", "Server"),
|
"Laptop",
|
||||||
("ComputerMonitor", "ComputerMonitor"),
|
"Server",
|
||||||
("TelevisionSet", "TelevisionSet"),
|
],
|
||||||
("Projector", "Projector"),
|
"Monitor": ["ComputerMonitor", "Monitor", "TelevisionSet", "Projector"],
|
||||||
("Mobile", "Mobile"),
|
"Mobile, tablet & smartphone": ["Mobile", "Tablet", "Smartphone", "Cellphone"],
|
||||||
("Smartphone", "Smartphone"),
|
"DataStorage": ["HardDrive", "SolidStateDrive"],
|
||||||
("Tablet", "Tablet"),
|
"Accessories & Peripherals": [
|
||||||
("Cellphone", "Cellphone"),
|
"GraphicCard",
|
||||||
("GraphicCard", "GraphicCard"),
|
"Motherboard",
|
||||||
("HardDrive", "HardDrive"),
|
"NetworkAdapter",
|
||||||
("SolidStateDrive", "SolidStateDrive"),
|
"Processor",
|
||||||
("Motherboard", "Motherboard"),
|
"RamModule",
|
||||||
("NetworkAdapter", "NetworkAdapter"),
|
"SoundCard",
|
||||||
("Processor", "Processor"),
|
"Battery",
|
||||||
("RamModule", "RamModule"),
|
"Keyboard",
|
||||||
("SoundCard", "SoundCard"),
|
"Mouse",
|
||||||
("Battery", "Battery"),
|
"MemoryCardReader",
|
||||||
("Keyboard", "Keyboard"),
|
],
|
||||||
("Mouse", "Mouse"),
|
}
|
||||||
("MemoryCardReader", "MemoryCardReader"),
|
|
||||||
("GraphicCard", "GraphicCard"),
|
|
||||||
("HardDrive", "HardDrive"),
|
|
||||||
("SolidStateDrive", "SolidStateDrive"),
|
|
||||||
("Motherboard", "Motherboard"),
|
|
||||||
("NetworkAdapter", "NetworkAdapter"),
|
|
||||||
("Processor", "Processor"),
|
|
||||||
("RamModule", "RamModule"),
|
|
||||||
("SoundCard", "SoundCard"),
|
|
||||||
("Battery", "Battery"),
|
|
||||||
("Keyboard", "Keyboard"),
|
|
||||||
("Mouse", "Mouse"),
|
|
||||||
("MemoryCardReader", "MemoryCardReader"),
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class FilterForm(FlaskForm):
|
class FilterForm(FlaskForm):
|
||||||
|
@ -97,18 +83,14 @@ class FilterForm(FlaskForm):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.device = dict(DEVICES).get(request.args.get('filter'))
|
types_of_devices = [item for sublist in DEVICES.values() for item in sublist]
|
||||||
|
dev = request.args.get('filter')
|
||||||
|
self.device = dev if dev in types_of_devices else None
|
||||||
if self.device:
|
if self.device:
|
||||||
self.filter.data = self.device
|
self.filter.data = self.device
|
||||||
|
|
||||||
def search(self):
|
def search(self):
|
||||||
|
|
||||||
if self.device == "Computer":
|
|
||||||
return ['Desktop', 'Laptop', 'Server']
|
|
||||||
|
|
||||||
if self.device == "DataStorage":
|
|
||||||
return ['HardDrive', 'SolidStateDrive']
|
|
||||||
|
|
||||||
if self.device:
|
if self.device:
|
||||||
return [self.device]
|
return [self.device]
|
||||||
|
|
||||||
|
|
|
@ -296,46 +296,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
{% for f in form_filter %}
|
{% for f in form_filter %}
|
||||||
{% if f == form_filter.filter %}
|
|
||||||
<select id="filter" class="form-select" name="filter">
|
|
||||||
<option value="All" {% if form_filter.filter.data == 'All' %}selected="selected"{% endif %}>All</option>
|
|
||||||
<optgroup label="Computer">
|
|
||||||
<option value="Desktop" {% if form_filter.filter.data == 'Desktop' %}selected="selected"{% endif %}>Desktop</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Laptop' %}selected="selected"{% endif %} value="Laptop">Laptop</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Server' %}selected="selected"{% endif %} value="Server">Server</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup label="Monitor">
|
|
||||||
<option value="ComputerMonitor" {% if form_filter.filter.data == 'ComputerMonitor' %}selected="selected"{% endif %}>ComputerMonitor</option>
|
|
||||||
<option {% if form_filter.filter.data == 'TelevisionSet' %}selected="selected"{% endif %} value="TelevisionSet">TelevisionSet</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Projector' %}selected="selected"{% endif %} value="Projector">Projector</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup label="Mobile, tablet & smartphone">
|
|
||||||
<option {% if form_filter.filter.data == 'Mobile' %}selected="selected"{% endif %} value="Mobile">Mobile</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Smartphone' %}selected="selected"{% endif %} value="Smartphone">Smartphone</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Tablet' %}selected="selected"{% endif %} value="Tablet">Tablet</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Cellphone' %}selected="selected"{% endif %} value="Cellphone">Cellphone</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup label="Data Storage">
|
|
||||||
<option {% if form_filter.filter.data == 'HardDrive' %}selected="selected"{% endif %} value="HardDrive">HardDrive</option>
|
|
||||||
<option {% if form_filter.filter.data == 'SolidStateDrive' %}selected="selected"{% endif %} value="SolidStateDrive">SolidStateDrive</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup label="Accessories & Peripherals">
|
|
||||||
<option {% if form_filter.filter.data == 'GraphicCard' %}selected="selected"{% endif %} value="GraphicCard">GraphicCard</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Motherboard' %}selected="selected"{% endif %} value="Motherboard">Motherboard</option>
|
|
||||||
<option {% if form_filter.filter.data == 'NetworkAdapter' %}selected="selected"{% endif %} value="NetworkAdapter">NetworkAdapter</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Processor' %}selected="selected"{% endif %} value="Processor">Processor</option>
|
|
||||||
<option {% if form_filter.filter.data == 'RamModule' %}selected="selected"{% endif %} value="RamModule">RamModule</option>
|
|
||||||
<option {% if form_filter.filter.data == 'SoundCard' %}selected="selected"{% endif %} value="SoundCard">SoundCard</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Battery' %}selected="selected"{% endif %} value="Battery">Battery</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Keyboard' %}selected="selected"{% endif %} value="Keyboard">Keyboard</option>
|
|
||||||
<option {% if form_filter.filter.data == 'Mouse' %}selected="selected"{% endif %} value="Mouse">Mouse</option>
|
|
||||||
<option {% if form_filter.filter.data == 'NetworkAdapter' %}selected="selected"{% endif %} value="NetworkAdapter">NetworkAdapter</option>
|
|
||||||
<option {% if form_filter.filter.data == 'MemoryCardReader' %}selected="selected"{% endif %} value="MemoryCardReader">MemoryCardReader</option>
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
|
||||||
{% else %}
|
|
||||||
{{ f }}
|
{{ f }}
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
|
|
Reference in New Issue