- Introduction of PARTNER_RAG retriever, PARTNER_RAG_SPECIALIST and linked Agent and Task, to support documentation inquiries in the management app (eveai_app)
- Addition of a tenant_partner_services view to show partner services from the viewpoint of a tenant - Addition of domain model diagrams - Addition of license_periods views and form
This commit is contained in:
@@ -3,7 +3,7 @@ from datetime import datetime as dt, timezone as tz
|
||||
from flask import flash
|
||||
from sqlalchemy import or_, desc
|
||||
|
||||
from common.models.entitlements import LicenseTier, License
|
||||
from common.models.entitlements import LicenseTier, License, LicensePeriod
|
||||
from common.services.user import PartnerServices, UserServices
|
||||
from common.utils.eveai_exceptions import EveAIException
|
||||
from common.utils.security_utils import current_user_has_role
|
||||
@@ -77,10 +77,16 @@ def get_license_tiers_list_view():
|
||||
'requiresSelection': False}
|
||||
]
|
||||
|
||||
# Add assign license action if user has permission
|
||||
# Add assign license actions if user has permission
|
||||
current_app.logger.debug(f"Adding specific buttons")
|
||||
if UserServices.can_user_assign_license():
|
||||
actions.insert(1, {'value': 'assign_license', 'text': 'Assign License', 'class': 'btn-info',
|
||||
'requiresSelection': True})
|
||||
current_app.logger.debug(f"Adding Create License for Tenant")
|
||||
actions.insert(1, {'value': 'create_license_for_tenant', 'text': 'Create License for Tenant',
|
||||
'class': 'btn-secondary', 'requiresSelection': True})
|
||||
if current_user_has_role('Super User'):
|
||||
current_app.logger.debug(f"Adding Associate License Tier to Partner")
|
||||
actions.insert(2, {'value': 'associate_license_tier_to_partner', 'text': 'Associate License Tier to Partner',
|
||||
'class': 'btn-secondary','requiresSelection': True})
|
||||
|
||||
# Initial sort configuration
|
||||
initial_sort = [{'column': 'start_date', 'dir': 'desc'}, {'column': 'id', 'dir': 'asc'}]
|
||||
@@ -139,7 +145,7 @@ def get_license_list_view():
|
||||
{'title': 'License Tier', 'field': 'license_tier_name'},
|
||||
{'title': 'Start Date', 'field': 'start_date', 'width': 120},
|
||||
{'title': 'Nr of Periods', 'field': 'nr_of_periods', 'width': 120},
|
||||
{'title': 'Active', 'field': 'active', 'formatter': 'tickCross', 'width': 100}
|
||||
{'title': 'Active', 'field': 'active', 'formatter': 'tickCross', 'width': 80}
|
||||
]
|
||||
|
||||
# Action definitions
|
||||
@@ -162,3 +168,74 @@ def get_license_list_view():
|
||||
'description': 'View and manage licenses',
|
||||
'table_height': 700
|
||||
}
|
||||
|
||||
|
||||
def get_license_periods_list_view(license_id):
|
||||
"""Generate the license periods list view configuration"""
|
||||
# Get the license object
|
||||
license = License.query.get_or_404(license_id)
|
||||
|
||||
# Get all periods for this license
|
||||
periods = (LicensePeriod.query
|
||||
.filter_by(license_id=license_id)
|
||||
.order_by(LicensePeriod.period_number)
|
||||
.all())
|
||||
|
||||
# Prepare data for Tabulator
|
||||
data = []
|
||||
for period in periods:
|
||||
# Get usage data
|
||||
usage = period.license_usage
|
||||
storage_used = usage.storage_mb_used if usage else 0
|
||||
embedding_used = usage.embedding_mb_used if usage else 0
|
||||
interaction_used = usage.interaction_total_tokens_used if usage else 0
|
||||
|
||||
# Get payment status
|
||||
prepaid_payment = period.prepaid_payment
|
||||
prepaid_status = prepaid_payment.status.name if prepaid_payment else 'N/A'
|
||||
|
||||
# Get invoice status
|
||||
prepaid_invoice = period.prepaid_invoice
|
||||
invoice_status = prepaid_invoice.status.name if prepaid_invoice else 'N/A'
|
||||
|
||||
data.append({
|
||||
'id': period.id,
|
||||
'period_number': period.period_number,
|
||||
'period_start': period.period_start.strftime('%Y-%m-%d'),
|
||||
'period_end': period.period_end.strftime('%Y-%m-%d'),
|
||||
'status': period.status.name,
|
||||
})
|
||||
|
||||
# Column definitions
|
||||
columns = [
|
||||
{'title': 'ID', 'field': 'id', 'width': 60, 'type': 'number'},
|
||||
{'title': 'Period', 'field': 'period_number'},
|
||||
{'title': 'Start Date', 'field': 'period_start'},
|
||||
{'title': 'End Date', 'field': 'period_end'},
|
||||
{'title': 'Status', 'field': 'status'},
|
||||
]
|
||||
|
||||
# Action definitions
|
||||
actions = [
|
||||
{'value': 'view_period_details', 'text': 'View Details', 'class': 'btn-primary', 'requiresSelection': True}
|
||||
]
|
||||
|
||||
# If user has admin roles, add transition action
|
||||
if current_user_has_role('Super User'):
|
||||
actions.append({'value': 'edit_license_period', 'text': 'Edit Period', 'class': 'btn-secondary', 'requiresSelection': True})
|
||||
|
||||
# Initial sort configuration
|
||||
initial_sort = [{'column': 'period_number', 'dir': 'asc'}]
|
||||
|
||||
return {
|
||||
'title': 'License Periods',
|
||||
'data': data,
|
||||
'columns': columns,
|
||||
'actions': actions,
|
||||
'initial_sort': initial_sort,
|
||||
'table_id': 'license_periods_table',
|
||||
'form_action': url_for('entitlements_bp.handle_license_period_selection', license_id=license_id),
|
||||
'description': f'View and manage periods for License {license_id}',
|
||||
'table_height': 700,
|
||||
'license': license
|
||||
}
|
||||
|
||||
@@ -10,9 +10,7 @@ def get_partners_list_view():
|
||||
# Haal alle partners op met hun tenant informatie
|
||||
query = (db.session.query(
|
||||
Partner.id,
|
||||
Partner.code,
|
||||
Partner.active,
|
||||
Partner.logo_url,
|
||||
Tenant.name.label('name')
|
||||
).join(Tenant, Partner.tenant_id == Tenant.id).order_by(Partner.id))
|
||||
|
||||
@@ -24,7 +22,6 @@ def get_partners_list_view():
|
||||
for partner in all_partners:
|
||||
data.append({
|
||||
'id': partner.id,
|
||||
'code': partner.code,
|
||||
'name': partner.name,
|
||||
'active': partner.active
|
||||
})
|
||||
@@ -32,7 +29,6 @@ def get_partners_list_view():
|
||||
# Kolomdefinities
|
||||
columns = [
|
||||
{'title': 'ID', 'field': 'id', 'width': 80},
|
||||
{'title': 'Code', 'field': 'code'},
|
||||
{'title': 'Name', 'field': 'name'},
|
||||
{'title': 'Active', 'field': 'active', 'formatter': 'tickCross'}
|
||||
]
|
||||
|
||||
@@ -3,7 +3,7 @@ from flask_security import roles_accepted
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
import ast
|
||||
|
||||
from common.models.user import Tenant, User, TenantDomain, TenantProject, TenantMake
|
||||
from common.models.user import Tenant, User, TenantDomain, TenantProject, TenantMake, PartnerTenant, PartnerService
|
||||
from common.services.user import UserServices
|
||||
from eveai_app.views.list_views.list_view_utils import render_list_view
|
||||
|
||||
@@ -232,3 +232,47 @@ def get_tenant_makes_list_view(tenant_id):
|
||||
'form_action': url_for('user_bp.handle_tenant_make_selection'),
|
||||
'description': f'Makes for tenant {tenant_id}'
|
||||
}
|
||||
|
||||
|
||||
# Tenant Partner Services list view helper
|
||||
def get_tenant_partner_services_list_view(tenant_id):
|
||||
"""Generate the tenant partner services list view configuration for a specific tenant"""
|
||||
# Get partner services for the tenant through PartnerTenant association
|
||||
query = PartnerService.query.join(PartnerTenant).filter(PartnerTenant.tenant_id == tenant_id)
|
||||
partner_services = query.all()
|
||||
|
||||
# Prepare data for Tabulator
|
||||
data = []
|
||||
for service in partner_services:
|
||||
data.append({
|
||||
'id': service.id,
|
||||
'name': service.name,
|
||||
'type': service.type,
|
||||
'type_version': service.type_version,
|
||||
'active': service.active
|
||||
})
|
||||
|
||||
# Column Definitions
|
||||
columns = [
|
||||
{'title': 'ID', 'field': 'id', 'width': 80},
|
||||
{'title': 'Name', 'field': 'name'},
|
||||
{'title': 'Type', 'field': 'type'},
|
||||
{'title': 'Version', 'field': 'type_version'},
|
||||
{'title': 'Active', 'field': 'active', 'formatter': 'tickCross', 'width': 120}
|
||||
]
|
||||
|
||||
# No actions needed as specified in requirements
|
||||
actions = []
|
||||
|
||||
initial_sort = [{'column': 'name', 'dir': 'asc'}]
|
||||
|
||||
return {
|
||||
'title': 'Partner Services',
|
||||
'data': data,
|
||||
'columns': columns,
|
||||
'actions': actions,
|
||||
'initial_sort': initial_sort,
|
||||
'table_id': 'tenant_partner_services_table',
|
||||
'form_action': url_for('user_bp.tenant_partner_services'),
|
||||
'description': f'Partner Services for tenant {tenant_id}'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user