add others device
This commit is contained in:
parent
b84f379468
commit
c392270676
|
@ -52,6 +52,7 @@ from ereuse_devicehub.resources.device.models import (
|
||||||
MemoryCardReader,
|
MemoryCardReader,
|
||||||
Monitor,
|
Monitor,
|
||||||
Mouse,
|
Mouse,
|
||||||
|
Other,
|
||||||
Placeholder,
|
Placeholder,
|
||||||
Projector,
|
Projector,
|
||||||
Server,
|
Server,
|
||||||
|
@ -84,7 +85,6 @@ DEVICES = {
|
||||||
],
|
],
|
||||||
"Mobile, tablet & smartphone": [
|
"Mobile, tablet & smartphone": [
|
||||||
"All Mobile",
|
"All Mobile",
|
||||||
"Mobile",
|
|
||||||
"Tablet",
|
"Tablet",
|
||||||
"Smartphone",
|
"Smartphone",
|
||||||
"Cellphone",
|
"Cellphone",
|
||||||
|
@ -101,6 +101,7 @@ DEVICES = {
|
||||||
"SAI",
|
"SAI",
|
||||||
"Keyboard",
|
"Keyboard",
|
||||||
],
|
],
|
||||||
|
"Other Devices": ["Other"],
|
||||||
}
|
}
|
||||||
|
|
||||||
COMPUTERS = ['Desktop', 'Laptop', 'Server', 'Computer']
|
COMPUTERS = ['Desktop', 'Laptop', 'Server', 'Computer']
|
||||||
|
@ -109,6 +110,7 @@ MONITORS = ["ComputerMonitor", "Monitor", "TelevisionSet", "Projector"]
|
||||||
MOBILE = ["Mobile", "Tablet", "Smartphone", "Cellphone"]
|
MOBILE = ["Mobile", "Tablet", "Smartphone", "Cellphone"]
|
||||||
STORAGE = ["HardDrive", "SolidStateDrive"]
|
STORAGE = ["HardDrive", "SolidStateDrive"]
|
||||||
ACCESSORIES = ["Mouse", "MemoryCardReader", "SAI", "Keyboard"]
|
ACCESSORIES = ["Mouse", "MemoryCardReader", "SAI", "Keyboard"]
|
||||||
|
OTHERS = ["Other"]
|
||||||
|
|
||||||
|
|
||||||
class AdvancedSearchForm(FlaskForm):
|
class AdvancedSearchForm(FlaskForm):
|
||||||
|
@ -181,7 +183,7 @@ class FilterForm(FlaskForm):
|
||||||
|
|
||||||
# Generic Filters
|
# Generic Filters
|
||||||
if "All Devices" == self.device_type:
|
if "All Devices" == self.device_type:
|
||||||
filter_type = COMPUTERS + MONITORS + MOBILE
|
filter_type = COMPUTERS + MONITORS + MOBILE + OTHERS
|
||||||
|
|
||||||
elif "All Computers" == self.device_type:
|
elif "All Computers" == self.device_type:
|
||||||
filter_type = COMPUTERS
|
filter_type = COMPUTERS
|
||||||
|
@ -392,6 +394,7 @@ class NewDeviceForm(FlaskForm):
|
||||||
"Keyboard": Keyboard,
|
"Keyboard": Keyboard,
|
||||||
"SAI": SAI,
|
"SAI": SAI,
|
||||||
"MemoryCardReader": MemoryCardReader,
|
"MemoryCardReader": MemoryCardReader,
|
||||||
|
"Other": Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
def reset_from_obj(self):
|
def reset_from_obj(self):
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
"""device other
|
||||||
|
|
||||||
|
Revision ID: 410aadae7652
|
||||||
|
Revises: d65745749e34
|
||||||
|
Create Date: 2022-11-29 12:00:40.272121
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import context, op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '410aadae7652'
|
||||||
|
down_revision = 'd65745749e34'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_inv():
|
||||||
|
INV = context.get_x_argument(as_dictionary=True).get('inventory')
|
||||||
|
if not INV:
|
||||||
|
raise ValueError("Inventory value is not specified")
|
||||||
|
return INV
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'other',
|
||||||
|
sa.Column('id', sa.BigInteger(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(
|
||||||
|
['id'],
|
||||||
|
[f'{get_inv()}.device.id'],
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint('id'),
|
||||||
|
schema=f'{get_inv()}',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_table('other', schema=f'{get_inv()}')
|
|
@ -695,3 +695,8 @@ class ManufacturerDef(Resource):
|
||||||
"""Loads the manufacturers to the database."""
|
"""Loads the manufacturers to the database."""
|
||||||
if exclude_schema != 'common':
|
if exclude_schema != 'common':
|
||||||
Manufacturer.add_all_to_session(db.session)
|
Manufacturer.add_all_to_session(db.session)
|
||||||
|
|
||||||
|
|
||||||
|
class OtherDef(DeviceDef):
|
||||||
|
VIEW = None
|
||||||
|
SCHEMA = schemas.Other
|
||||||
|
|
|
@ -1637,3 +1637,11 @@ def create_code_tag(mapper, connection, device):
|
||||||
|
|
||||||
# from flask_sqlalchemy import event
|
# from flask_sqlalchemy import event
|
||||||
# event.listen(Device, 'after_insert', create_code_tag, propagate=True)
|
# event.listen(Device, 'after_insert', create_code_tag, propagate=True)
|
||||||
|
|
||||||
|
|
||||||
|
class Other(Device):
|
||||||
|
"""
|
||||||
|
Used for put in there all devices than not have actualy a class
|
||||||
|
"""
|
||||||
|
|
||||||
|
id = Column(BigInteger, ForeignKey(Device.id), primary_key=True)
|
||||||
|
|
|
@ -581,3 +581,7 @@ class Bike(Recreation):
|
||||||
|
|
||||||
class Racket(Recreation):
|
class Racket(Recreation):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Other(Device):
|
||||||
|
pass
|
||||||
|
|
|
@ -72,6 +72,10 @@
|
||||||
<option value="Keyboard"
|
<option value="Keyboard"
|
||||||
{% if form.type.data == 'Keyboard' %} selected="selected"{% endif %}>Keyboard</option>
|
{% if form.type.data == 'Keyboard' %} selected="selected"{% endif %}>Keyboard</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
<optgroup label="Other Type of Device">
|
||||||
|
<option value="Other"
|
||||||
|
{% if form.type.data == 'Other' %} selected="selected"{% endif %}>Other</option>
|
||||||
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
<small class="text-muted form-text">Type of devices</small>
|
<small class="text-muted form-text">Type of devices</small>
|
||||||
{% if form.type.errors %}
|
{% if form.type.errors %}
|
||||||
|
|
Reference in New Issue