Skip to content
Snippets Groups Projects
Commit ccf0447d authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Remove name column from Item

Most items won't have a name.
hostname could be added in a separate table if required.
parent a738d0b4
No related branches found
No related tags found
No related merge requests found
......@@ -98,7 +98,6 @@ def patch_item(item_id):
item = Item.query.get(item_id)
if item is None:
raise utils.InventoryError(f'Unknown item id: {item_id}', status_code=422)
item.name = data.get('name', item.name)
item.manufacturer = utils.convert_to_model(data.get('manufacturer', item.manufacturer), Manufacturer)
item.model = utils.convert_to_model(data.get('model', item.model), Model)
item.location = utils.convert_to_model(data.get('location', item.location), Location)
......
......@@ -42,7 +42,6 @@ def retrieve_items():
items = Item.query.order_by(Item._created)
data = [[item.id,
item.serial_number,
item.name,
utils.format_field(item.manufacturer),
utils.format_field(item.model),
utils.format_field(item.location),
......
......@@ -220,7 +220,6 @@ class Item(db.Model):
_created = db.Column(db.DateTime, default=db.func.now())
_updated = db.Column(db.DateTime, default=db.func.now(), onupdate=db.func.now())
serial_number = db.Column(db.String(100), nullable=False)
name = db.Column(db.String(100))
hash = db.Column(GUID, unique=True)
manufacturer_id = db.Column(db.Integer, db.ForeignKey('manufacturer.id'))
model_id = db.Column(db.Integer, db.ForeignKey('model.id'))
......@@ -234,10 +233,9 @@ class Item(db.Model):
status = db.relationship('Status', back_populates='items')
children = db.relationship('Item', backref=db.backref('parent', remote_side=[id]))
def __init__(self, serial_number=None, name=None, manufacturer=None, model=None, location=None, status=None):
def __init__(self, serial_number=None, manufacturer=None, model=None, location=None, status=None):
# All arguments must be optional for this class to work with flask-admin!
self.serial_number = serial_number
self.name = name
self.manufacturer = utils.convert_to_model(manufacturer, Manufacturer)
self.model = utils.convert_to_model(model, Model)
self.location = utils.convert_to_model(location, Location)
......@@ -251,7 +249,6 @@ class Item(db.Model):
return {
'id': self.id,
'serial_number': self.serial_number,
'name': self.name,
'hash': self.hash,
'manufacturer': utils.format_field(self.manufacturer),
'model': utils.format_field(self.model),
......
......@@ -10,7 +10,6 @@
<tr>
<th>Id</th>
<th>Serial number</th>
<th>name</th>
<th>Manufacturer</th>
<th>Model</th>
<th>Location</th>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment