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
|
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)
|
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:
|
if system_state is not None and system_state.profile_id is profile.id:
|
||||||
return ConnectionController.system_uses_wireguard_interface()
|
return ConnectionController.system_uses_wireguard_interface()
|
||||||
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_invoice(profile: Union[SessionProfile, SystemProfile]):
|
def get_invoice(profile: Union[SessionProfile, SystemProfile]):
|
||||||
|
|
||||||
if profile.subscription is None:
|
if profile.has_subscription():
|
||||||
return None
|
|
||||||
|
|
||||||
return WebServiceApiService.get_invoice(profile.subscription.billing_code)
|
return WebServiceApiService.get_invoice(profile.subscription.billing_code)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def attach_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
def attach_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
||||||
|
|
||||||
if not profile.is_session_profile():
|
if profile.is_session_profile() and profile.has_subscription():
|
||||||
return None
|
|
||||||
|
|
||||||
if profile.subscription is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
proxy_configuration = WebServiceApiService.get_proxy_configuration(profile.subscription.billing_code)
|
proxy_configuration = WebServiceApiService.get_proxy_configuration(profile.subscription.billing_code)
|
||||||
|
|
||||||
|
@ -203,11 +198,11 @@ class ProfileController:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
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
|
return None
|
||||||
|
|
||||||
profile.get_proxy_configuration()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def has_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
def has_proxy_configuration(profile: Union[SessionProfile, SystemProfile]):
|
||||||
profile.has_proxy_configuration()
|
profile.has_proxy_configuration()
|
||||||
|
@ -217,10 +212,10 @@ class ProfileController:
|
||||||
|
|
||||||
from core.controllers.ConnectionController import ConnectionController
|
from core.controllers.ConnectionController import ConnectionController
|
||||||
|
|
||||||
if profile.subscription is None:
|
if not profile.has_subscription():
|
||||||
raise MissingSubscriptionError()
|
raise MissingSubscriptionError()
|
||||||
|
|
||||||
if profile.location is None:
|
if not profile.has_location():
|
||||||
raise MissingLocationError()
|
raise MissingLocationError()
|
||||||
|
|
||||||
wireguard_keys = ProfileController.__generate_wireguard_keys()
|
wireguard_keys = ProfileController.__generate_wireguard_keys()
|
||||||
|
|
Loading…
Reference in a new issue