Rollback
Dieser Commit ist enthalten in:
@@ -124,4 +124,48 @@ def prepare_audit_export_data(audit_logs):
|
||||
str(log['new_values']) if log['new_values'] else '',
|
||||
log['additional_info'] or ''
|
||||
])
|
||||
return export_data
|
||||
return export_data
|
||||
|
||||
|
||||
def create_batch_export(licenses):
|
||||
"""Create Excel export for batch licenses"""
|
||||
export_data = []
|
||||
|
||||
for license in licenses:
|
||||
export_data.append({
|
||||
'Lizenzschlüssel': license['license_key'],
|
||||
'Kunde': license.get('customer_name', ''),
|
||||
'Email': license.get('email', ''),
|
||||
'Max. Benutzer': license.get('max_users', 1),
|
||||
'Geräte-Limit': license.get('device_limit', 1),
|
||||
'Gültig von': format_datetime_for_export(license.get('valid_from')),
|
||||
'Gültig bis': format_datetime_for_export(license.get('valid_until')),
|
||||
'Status': 'Aktiv' if license.get('is_active', True) else 'Inaktiv',
|
||||
'Test-Lizenz': 'Ja' if license.get('is_test', False) else 'Nein'
|
||||
})
|
||||
|
||||
df = pd.DataFrame(export_data)
|
||||
|
||||
# Create Excel file in memory
|
||||
output = BytesIO()
|
||||
with pd.ExcelWriter(output, engine='openpyxl') as writer:
|
||||
df.to_excel(writer, index=False, sheet_name='Batch-Lizenzen')
|
||||
|
||||
# Auto-adjust column widths
|
||||
worksheet = writer.sheets['Batch-Lizenzen']
|
||||
for idx, col in enumerate(df.columns):
|
||||
max_length = max(df[col].astype(str).map(len).max(), len(col)) + 2
|
||||
worksheet.column_dimensions[get_column_letter(idx + 1)].width = min(max_length, 50)
|
||||
|
||||
output.seek(0)
|
||||
|
||||
# Generate filename with timestamp
|
||||
timestamp = datetime.now(ZoneInfo("Europe/Berlin")).strftime('%Y%m%d_%H%M%S')
|
||||
filename = f"batch_licenses_{timestamp}.xlsx"
|
||||
|
||||
return send_file(
|
||||
output,
|
||||
mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
as_attachment=True,
|
||||
download_name=filename
|
||||
)
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren