Lizenzübersicht besser
Dieser Commit ist enthalten in:
@@ -24,47 +24,48 @@ def licenses():
|
||||
|
||||
# Get filter parameters
|
||||
search = request.args.get('search', '').strip()
|
||||
filter_types = request.args.getlist('types[]') # Multi-select for types
|
||||
filter_statuses = request.args.getlist('statuses[]') # Multi-select for statuses
|
||||
data_source = request.args.get('data_source', 'real') # real, fake, all
|
||||
license_type = request.args.get('license_type', '') # '', full, test
|
||||
license_status = request.args.get('license_status', '') # '', active, expiring, expired, inactive
|
||||
sort = request.args.get('sort', 'created_at')
|
||||
order = request.args.get('order', 'desc')
|
||||
page = request.args.get('page', 1, type=int)
|
||||
per_page = 50
|
||||
|
||||
# Get all licenses (both fake and real data)
|
||||
licenses_list = get_licenses(show_fake=True)
|
||||
# Get licenses based on data source
|
||||
if data_source == 'fake':
|
||||
licenses_list = get_licenses(show_fake=True)
|
||||
licenses_list = [l for l in licenses_list if l.get('is_fake')]
|
||||
elif data_source == 'all':
|
||||
licenses_list = get_licenses(show_fake=True)
|
||||
else: # real
|
||||
licenses_list = get_licenses(show_fake=False)
|
||||
|
||||
# Type filtering with OR logic
|
||||
if filter_types:
|
||||
filtered_by_type = []
|
||||
for license in licenses_list:
|
||||
# Check if license matches any selected type
|
||||
if 'full' in filter_types and license.get('license_type') == 'full' and not license.get('is_fake'):
|
||||
filtered_by_type.append(license)
|
||||
elif 'test' in filter_types and license.get('license_type') == 'test' and not license.get('is_fake'):
|
||||
filtered_by_type.append(license)
|
||||
licenses_list = filtered_by_type
|
||||
else:
|
||||
# If no types selected, show only real data by default
|
||||
licenses_list = [l for l in licenses_list if not l.get('is_fake')]
|
||||
# Type filtering
|
||||
if license_type:
|
||||
if license_type == 'full':
|
||||
licenses_list = [l for l in licenses_list if l.get('license_type') == 'full']
|
||||
elif license_type == 'test':
|
||||
licenses_list = [l for l in licenses_list if l.get('license_type') == 'test']
|
||||
|
||||
# Status filtering with OR logic
|
||||
if filter_statuses:
|
||||
now = datetime.now()
|
||||
filtered_by_status = []
|
||||
# Status filtering
|
||||
if license_status:
|
||||
now = datetime.now().date()
|
||||
filtered_licenses = []
|
||||
|
||||
for license in licenses_list:
|
||||
# Check if license matches any selected status
|
||||
if 'active' in filter_statuses and license.get('is_active') and license.get('valid_until') and license.get('valid_until') > now:
|
||||
filtered_by_status.append(license)
|
||||
elif 'expiring' in filter_statuses:
|
||||
if license_status == 'active' and license.get('is_active') and license.get('valid_until') and license.get('valid_until') > now:
|
||||
filtered_licenses.append(license)
|
||||
elif license_status == 'expiring':
|
||||
expiry_threshold = now + timedelta(days=30)
|
||||
if license.get('valid_until') and now < license.get('valid_until') <= expiry_threshold:
|
||||
filtered_by_status.append(license)
|
||||
elif 'expired' in filter_statuses and license.get('valid_until') and license.get('valid_until') <= now:
|
||||
filtered_by_status.append(license)
|
||||
elif 'inactive' in filter_statuses and not license.get('is_active'):
|
||||
filtered_by_status.append(license)
|
||||
licenses_list = filtered_by_status
|
||||
filtered_licenses.append(license)
|
||||
elif license_status == 'expired' and license.get('valid_until') and license.get('valid_until') <= now:
|
||||
filtered_licenses.append(license)
|
||||
elif license_status == 'inactive' and not license.get('is_active'):
|
||||
filtered_licenses.append(license)
|
||||
|
||||
licenses_list = filtered_licenses
|
||||
|
||||
# Search filtering
|
||||
if search:
|
||||
@@ -84,8 +85,9 @@ def licenses():
|
||||
return render_template("licenses.html",
|
||||
licenses=licenses_list,
|
||||
search=search,
|
||||
filter_types=filter_types,
|
||||
filter_statuses=filter_statuses,
|
||||
data_source=data_source,
|
||||
license_type=license_type,
|
||||
license_status=license_status,
|
||||
sort=sort,
|
||||
order=order,
|
||||
page=page,
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren