Cleanup .pyc and .DS_Store, add new modules, remove legacy services
This commit is contained in:
47
common/services/user/partner_services.py
Normal file
47
common/services/user/partner_services.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from typing import List
|
||||
|
||||
from flask import session
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from common.models.entitlements import PartnerServiceLicenseTier
|
||||
from common.utils.eveai_exceptions import EveAINoManagementPartnerService, EveAINoSessionPartner
|
||||
|
||||
from common.utils.security_utils import current_user_has_role
|
||||
|
||||
|
||||
class PartnerServices:
|
||||
@staticmethod
|
||||
def get_allowed_license_tier_ids() -> List[int]:
|
||||
"""
|
||||
Retrieve IDs of all License Tiers associated with the partner's management service
|
||||
|
||||
Returns:
|
||||
List of license tier IDs
|
||||
|
||||
Raises:
|
||||
EveAINoSessionPartner: If no partner is in the session
|
||||
EveAINoManagementPartnerService: If partner has no management service
|
||||
"""
|
||||
partner = session.get("partner", None)
|
||||
if not partner:
|
||||
raise EveAINoSessionPartner()
|
||||
|
||||
# Find a management service for this partner
|
||||
management_service = next((service for service in session['partner']['services']
|
||||
if service.get('type') == 'MANAGEMENT_SERVICE'), None)
|
||||
if not management_service:
|
||||
raise EveAINoManagementPartnerService()
|
||||
management_service_id = management_service['id']
|
||||
|
||||
# Query for all license tiers associated with this management service
|
||||
associations = PartnerServiceLicenseTier.query.filter_by(
|
||||
partner_service_id=management_service_id
|
||||
).all()
|
||||
|
||||
# Extract the license tier IDs
|
||||
license_tier_ids = [assoc.license_tier_id for assoc in associations]
|
||||
|
||||
return license_tier_ids
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user