- Add Notes field in inventory item
This commit is contained in:
Takeus committed 2025-11-02 21:24:20 +01:00
1 parent 5c5a174209
commit 03e543e7f8
4 files changed
+18 -1

No files matched your search

+3
View File
@@ -48,3 +48,6 @@ class ChangeInventoryItem(FlaskForm):
item_contact = StringField(validators=[Length(max=64)]) item_contact = StringField(validators=[Length(max=64)])
# Allocation(s) # Allocation(s)
item_ip_allocations = StringField() item_ip_allocations = StringField()
# Others
item_notes = StringField()
+2
View File
@@ -47,3 +47,5 @@ class Inventory(db.Model):
host_contact = db.Column(db.String(64)) host_contact = db.Column(db.String(64))
## Allocation(s) ## Allocation(s)
host_allocations = db.Column(db.Text()) host_allocations = db.Column(db.Text())
### Others
host_notes = db.Column(db.Text())
+7
View File
@@ -104,6 +104,7 @@ def item_view_modal(item_id):
('Owner',db_item.host_owner,'col-6'), ('Owner',db_item.host_owner,'col-6'),
('Contact',db_item.host_contact,'col-6'), ('Contact',db_item.host_contact,'col-6'),
('Allocations',db_item.host_allocations,'col-12'), ('Allocations',db_item.host_allocations,'col-12'),
('Notes',db_item.host_notes,'col-12'),
] ]
return render_template('panel/_modal.html', modal=modal, item_id=item_id, informations=informations, old_page=request.args.get('page', type=int), pagination_active=True) return render_template('panel/_modal.html', modal=modal, item_id=item_id, informations=informations, old_page=request.args.get('page', type=int), pagination_active=True)
@@ -175,6 +176,11 @@ def item_edit_modal(item_id):
db_item.host_contact = form.item_contact.data db_item.host_contact = form.item_contact.data
else: else:
db_item.host_contact = None db_item.host_contact = None
# Notes
if form.item_notes.data != '' and form.item_notes.data != 'None':
db_item.host_notes = form.item_notes.data
else:
db_item.host_notes = None
# Allocations # Allocations
db_existing_allocs = Allocation.query.filter_by(device_id=db_item.id).all() db_existing_allocs = Allocation.query.filter_by(device_id=db_item.id).all()
@@ -219,6 +225,7 @@ def item_edit_modal(item_id):
form.item_owner.default = db_item.host_owner form.item_owner.default = db_item.host_owner
form.item_contact.default = db_item.host_contact form.item_contact.default = db_item.host_contact
form.item_ip_allocations.default = db_item.host_allocations form.item_ip_allocations.default = db_item.host_allocations
form.item_notes.default = db_item.host_notes
form.process() form.process()
modal = { modal = {
+6 -1
View File
@@ -13,7 +13,12 @@
<div class="row"> <div class="row">
{% for entry in form %} {% for entry in form %}
{% if entry.id != 'csrf_token' %} {% if entry.id != 'csrf_token' %}
{% if entry.id == 'item_ip_allocations' %} {% if entry.id == 'item_notes' %}
<div class="col-12">
{{ entry.label(class="form-label") }}<br>
{{ entry(class="form-control",placeholder='Notes, EX : Patch Panel/Switch...') }}
</div>
{% elif entry.id == 'item_ip_allocations' %}
<div class="col-12"> <div class="col-12">
{{ entry.label(class="form-label") }}<br> {{ entry.label(class="form-label") }}<br>
{{ entry(class="form-control",placeholder='192.168.1.1,192.168.1.2 (separate with ,)') }} {{ entry(class="form-control",placeholder='192.168.1.1,192.168.1.2 (separate with ,)') }}