Refactoring - Fix2

Dieser Commit ist enthalten in:
2025-06-18 00:07:34 +02:00
Ursprung 0ec0d2c267
Commit a9cfecc699
18 geänderte Dateien mit 1412 neuen und 337 gelöschten Zeilen

Datei anzeigen

@@ -20,9 +20,14 @@ license_bp = Blueprint('licenses', __name__)
@license_bp.route("/licenses")
@login_required
def licenses():
from datetime import datetime, timedelta
show_test = request.args.get('show_test', 'false') == 'true'
licenses_list = get_licenses(show_test=show_test)
return render_template("licenses.html", licenses=licenses_list, show_test=show_test)
return render_template("licenses.html",
licenses=licenses_list,
show_test=show_test,
now=datetime.now,
timedelta=timedelta)
@license_bp.route("/license/edit/<int:license_id>", methods=["GET", "POST"])
@@ -41,26 +46,28 @@ def edit_license(license_id):
# Update license data
new_values = {
'customer_name': request.form['customer_name'],
'customer_email': request.form['customer_email'],
'license_key': request.form['license_key'],
'license_type': request.form['license_type'],
'valid_from': request.form['valid_from'],
'valid_until': request.form['valid_until'],
'device_limit': int(request.form['device_limit']),
'active': 'active' in request.form
'is_active': 'is_active' in request.form,
'is_test': 'is_test' in request.form,
'device_limit': int(request.form.get('device_limit', 3))
}
cur.execute("""
UPDATE licenses
SET customer_name = %s, customer_email = %s, valid_from = %s,
valid_until = %s, device_limit = %s, active = %s
SET license_key = %s, license_type = %s, valid_from = %s,
valid_until = %s, is_active = %s, is_test = %s, device_limit = %s
WHERE id = %s
""", (
new_values['customer_name'],
new_values['customer_email'],
new_values['license_key'],
new_values['license_type'],
new_values['valid_from'],
new_values['valid_until'],
new_values['is_active'],
new_values['is_test'],
new_values['device_limit'],
new_values['active'],
license_id
))
@@ -69,12 +76,13 @@ def edit_license(license_id):
# Log changes
log_audit('UPDATE', 'license', license_id,
old_values={
'customer_name': current_license['customer_name'],
'customer_email': current_license['customer_email'],
'valid_from': str(current_license['valid_from']),
'valid_until': str(current_license['valid_until']),
'device_limit': current_license['device_limit'],
'active': current_license['active']
'license_key': current_license.get('license_key'),
'license_type': current_license.get('license_type'),
'valid_from': str(current_license.get('valid_from', '')),
'valid_until': str(current_license.get('valid_until', '')),
'is_active': current_license.get('is_active'),
'is_test': current_license.get('is_test'),
'device_limit': current_license.get('device_limit', 3)
},
new_values=new_values)