Update and refactor existing codebase
This commit is contained in:
parent
4d56dd0a8c
commit
3ff73cd079
1 changed files with 14 additions and 19 deletions
|
@ -143,7 +143,7 @@ class ProfileController:
|
|||
|
||||
from core.controllers.ConnectionController import ConnectionController
|
||||
|
||||
if profile.subscription is not None:
|
||||
if profile.has_subscription():
|
||||
|
||||
subscription = ConnectionController.with_preferred_connection(profile.subscription.billing_code, task=WebServiceApiService.get_subscription, connection_observer=connection_observer)
|
||||
|
||||
|
@ -175,25 +175,20 @@ class ProfileController:
|
|||
if system_state is not None and system_state.profile_id is profile.id:
|
||||
return ConnectionController.system_uses_wireguard_interface()
|
||||
|
||||
else:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def get_invoice(profile: Union[SessionProfile, SystemProfile]):
|
||||
|
||||
if profile.subscription is None:
|
||||
return None
|
||||
|
||||
if profile.has_subscription():
|
||||
return WebServiceApiService.get_invoice(profile.subscription.billing_code)
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def attach_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
||||
|
||||
if not profile.is_session_profile():
|
||||
return None
|
||||
|
||||
if profile.subscription is None:
|
||||
return None
|
||||
if profile.is_session_profile() and profile.has_subscription():
|
||||
|
||||
proxy_configuration = WebServiceApiService.get_proxy_configuration(profile.subscription.billing_code)
|
||||
|
||||
|
@ -203,11 +198,11 @@ class ProfileController:
|
|||
@staticmethod
|
||||
def get_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
||||
|
||||
if not profile.is_session_profile():
|
||||
if profile.is_session_profile():
|
||||
return profile.get_proxy_configuration()
|
||||
else:
|
||||
return None
|
||||
|
||||
profile.get_proxy_configuration()
|
||||
|
||||
@staticmethod
|
||||
def has_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
||||
profile.has_proxy_configuration()
|
||||
|
@ -217,10 +212,10 @@ class ProfileController:
|
|||
|
||||
from core.controllers.ConnectionController import ConnectionController
|
||||
|
||||
if profile.subscription is None:
|
||||
if not profile.has_subscription():
|
||||
raise MissingSubscriptionError()
|
||||
|
||||
if profile.location is None:
|
||||
if not profile.has_location():
|
||||
raise MissingLocationError()
|
||||
|
||||
wireguard_keys = ProfileController.__generate_wireguard_keys()
|
||||
|
|
Loading…
Reference in a new issue