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.models import User
|
||||
|
||||
DEVICES = [
|
||||
("All", "All"),
|
||||
("Desktop", "Desktop"),
|
||||
("Laptop", "Laptop"),
|
||||
("Server", "Server"),
|
||||
("ComputerMonitor", "ComputerMonitor"),
|
||||
("TelevisionSet", "TelevisionSet"),
|
||||
("Projector", "Projector"),
|
||||
("Mobile", "Mobile"),
|
||||
("Smartphone", "Smartphone"),
|
||||
("Tablet", "Tablet"),
|
||||
("Cellphone", "Cellphone"),
|
||||
("GraphicCard", "GraphicCard"),
|
||||
("HardDrive", "HardDrive"),
|
||||
("SolidStateDrive", "SolidStateDrive"),
|
||||
("Motherboard", "Motherboard"),
|
||||
("NetworkAdapter", "NetworkAdapter"),
|
||||
("Processor", "Processor"),
|
||||
("RamModule", "RamModule"),
|
||||
("SoundCard", "SoundCard"),
|
||||
("Battery", "Battery"),
|
||||
("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"),
|
||||
]
|
||||
DEVICES = {
|
||||
"All": ["All"],
|
||||
"Computer": [
|
||||
"Desktop",
|
||||
"Laptop",
|
||||
"Server",
|
||||
],
|
||||
"Monitor": ["ComputerMonitor", "Monitor", "TelevisionSet", "Projector"],
|
||||
"Mobile, tablet & smartphone": ["Mobile", "Tablet", "Smartphone", "Cellphone"],
|
||||
"DataStorage": ["HardDrive", "SolidStateDrive"],
|
||||
"Accessories & Peripherals": [
|
||||
"GraphicCard",
|
||||
"Motherboard",
|
||||
"NetworkAdapter",
|
||||
"Processor",
|
||||
"RamModule",
|
||||
"SoundCard",
|
||||
"Battery",
|
||||
"Keyboard",
|
||||
"Mouse",
|
||||
"MemoryCardReader",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
class FilterForm(FlaskForm):
|
||||
|
@ -97,18 +83,14 @@ class FilterForm(FlaskForm):
|
|||
|
||||
def __init__(self, *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:
|
||||
self.filter.data = self.device
|
||||
|
||||
def search(self):
|
||||
|
||||
if self.device == "Computer":
|
||||
return ['Desktop', 'Laptop', 'Server']
|
||||
|
||||
if self.device == "DataStorage":
|
||||
return ['HardDrive', 'SolidStateDrive']
|
||||
|
||||
if self.device:
|
||||
return [self.device]
|
||||
|
||||
|
|
|
@ -296,46 +296,7 @@
|
|||
<div class="row">
|
||||
<div class="col-2">
|
||||
{% 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 }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="col-1">
|
||||
|
|
Reference in New Issue