fixed view and aded setings and user api

This commit is contained in:
2026-05-10 17:05:59 +03:00
parent e63b486ec2
commit 48f43fcd60
3 changed files with 16 additions and 13 deletions
+4 -3
View File
@@ -95,8 +95,9 @@ def create():
return render_template('assets/form.html', asset=None,
asset_types=ASSET_TYPES, asset_statuses=ASSET_STATUSES)
service_tag = request.form.get('service_tag', '').strip() or None
if service_tag and Asset.query.filter_by(service_tag=service_tag).first():
# Service tag mirrors the serial number (same identifier)
service_tag = sn
if Asset.query.filter(Asset.service_tag == service_tag, Asset.serial_number != sn).first():
flash(f'An asset with service tag {service_tag} already exists.', 'danger')
return render_template('assets/form.html', asset=None,
asset_types=ASSET_TYPES, asset_statuses=ASSET_STATUSES)
@@ -223,7 +224,7 @@ def edit(asset_id):
asset_types=ASSET_TYPES, asset_statuses=ASSET_STATUSES)
asset.serial_number = new_sn
asset.service_tag = request.form.get('service_tag', '').strip() or None
asset.service_tag = new_sn # service tag mirrors serial number
asset.asset_tag = request.form.get('asset_tag', '').strip() or None
asset.asset_type = request.form.get('asset_type', asset.asset_type)
asset.brand = request.form.get('brand', '').strip() or None