Die UNterscheidung von Test und Echt Lizenzen ist strikter

Dieser Commit ist enthalten in:
2025-06-21 20:15:50 +02:00
Ursprung fdf74c11ec
Commit 08e4e939ab
3 geänderte Dateien mit 103 neuen und 7 gelöschten Zeilen

Datei anzeigen

@@ -42,6 +42,12 @@ def batch_create():
valid_from = request.form['valid_from']
valid_until = request.form['valid_until']
device_limit = int(request.form['device_limit'])
# Resource allocation parameters
domain_count = int(request.form.get('domain_count', 0))
ipv4_count = int(request.form.get('ipv4_count', 0))
phone_count = int(request.form.get('phone_count', 0))
# Validierung
if count < 1 or count > 100:
flash('Anzahl muss zwischen 1 und 100 liegen!', 'error')
@@ -90,6 +96,59 @@ def batch_create():
'license_key': license_key
})
# Allocate resources if requested
if domain_count > 0 or ipv4_count > 0 or phone_count > 0:
# Allocate domains
if domain_count > 0:
cur.execute("""
UPDATE resource_pool
SET status = 'allocated',
license_id = %s,
allocated_at = NOW()
WHERE id IN (
SELECT id FROM resource_pool
WHERE type = 'domain'
AND status = 'available'
AND is_fake = %s
ORDER BY id
LIMIT %s
)
""", (license_id, is_fake, domain_count))
# Allocate IPv4s
if ipv4_count > 0:
cur.execute("""
UPDATE resource_pool
SET status = 'allocated',
license_id = %s,
allocated_at = NOW()
WHERE id IN (
SELECT id FROM resource_pool
WHERE type = 'ipv4'
AND status = 'available'
AND is_fake = %s
ORDER BY id
LIMIT %s
)
""", (license_id, is_fake, ipv4_count))
# Allocate phones
if phone_count > 0:
cur.execute("""
UPDATE resource_pool
SET status = 'allocated',
license_id = %s,
allocated_at = NOW()
WHERE id IN (
SELECT id FROM resource_pool
WHERE type = 'phone'
AND status = 'available'
AND is_fake = %s
ORDER BY id
LIMIT %s
)
""", (license_id, is_fake, phone_count))
# Audit-Log
log_audit('CREATE', 'license', license_id,
new_values={