Batch Lizenzen funktionieren wieder
Dieser Commit ist enthalten in:
@@ -38,7 +38,7 @@ def batch_create():
|
||||
# Form data
|
||||
customer_id = int(request.form['customer_id'])
|
||||
license_type = request.form['license_type']
|
||||
count = int(request.form['count'])
|
||||
count = int(request.form['quantity']) # Korrigiert von 'count' zu 'quantity'
|
||||
valid_from = request.form['valid_from']
|
||||
valid_until = request.form['valid_until']
|
||||
device_limit = int(request.form['device_limit'])
|
||||
@@ -72,15 +72,15 @@ def batch_create():
|
||||
# Erstelle Lizenz
|
||||
cur.execute("""
|
||||
INSERT INTO licenses (
|
||||
license_key, customer_id, customer_name, customer_email,
|
||||
license_key, customer_id,
|
||||
license_type, valid_from, valid_until, device_limit,
|
||||
is_test, created_at, created_by
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
is_test, created_at
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING id
|
||||
""", (
|
||||
license_key, customer_id, customer[0], customer[1],
|
||||
license_key, customer_id,
|
||||
license_type, valid_from, valid_until, device_limit,
|
||||
is_test, datetime.now(), session['username']
|
||||
is_test, datetime.now()
|
||||
))
|
||||
|
||||
license_id = cur.fetchone()[0]
|
||||
@@ -101,6 +101,8 @@ def batch_create():
|
||||
|
||||
# Speichere erstellte Lizenzen in Session für Export
|
||||
session['batch_created_licenses'] = created_licenses
|
||||
session['batch_customer_name'] = customer[0]
|
||||
session['batch_customer_email'] = customer[1]
|
||||
|
||||
flash(f'{count} Lizenzen erfolgreich erstellt!', 'success')
|
||||
|
||||
@@ -137,10 +139,11 @@ def batch_export():
|
||||
|
||||
cur.execute("""
|
||||
SELECT
|
||||
l.license_key, l.customer_name, l.customer_email,
|
||||
l.license_key, c.name, c.email,
|
||||
l.license_type, l.valid_from, l.valid_until,
|
||||
l.device_limit, l.is_test, l.created_at
|
||||
FROM licenses l
|
||||
JOIN customers c ON l.customer_id = c.id
|
||||
WHERE l.id = ANY(%s)
|
||||
ORDER BY l.id
|
||||
""", (license_ids,))
|
||||
@@ -159,20 +162,13 @@ def batch_export():
|
||||
'created_at': row[8]
|
||||
})
|
||||
|
||||
# Erstelle Excel-Export
|
||||
excel_file = create_batch_export(licenses)
|
||||
|
||||
# Lösche aus Session
|
||||
session.pop('batch_created_licenses', None)
|
||||
session.pop('batch_customer_name', None)
|
||||
session.pop('batch_customer_email', None)
|
||||
|
||||
# Sende Datei
|
||||
filename = f"batch_licenses_{datetime.now().strftime('%Y%m%d_%H%M%S')}.xlsx"
|
||||
return send_file(
|
||||
excel_file,
|
||||
mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
as_attachment=True,
|
||||
download_name=filename
|
||||
)
|
||||
# Erstelle und sende Excel-Export
|
||||
return create_batch_export(licenses)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Fehler beim Export: {str(e)}")
|
||||
@@ -336,16 +332,16 @@ def batch_import():
|
||||
# Erstelle Lizenz
|
||||
cur.execute("""
|
||||
INSERT INTO licenses (
|
||||
license_key, customer_id, customer_name, customer_email,
|
||||
license_key, customer_id,
|
||||
license_type, valid_from, valid_until, device_limit,
|
||||
is_test, created_at, created_by
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
is_test, created_at
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING id
|
||||
""", (
|
||||
license_key, customer_id, customer_name, email,
|
||||
license_key, customer_id,
|
||||
row['license_type'], row['valid_from'], row['valid_until'],
|
||||
int(row['device_limit']), row.get('is_test', False),
|
||||
datetime.now(), session['username']
|
||||
datetime.now()
|
||||
))
|
||||
|
||||
license_id = cur.fetchone()[0]
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren