Update and refactor existing codebase
This commit is contained in:
parent
89741efdc7
commit
c744d9329d
3 changed files with 9 additions and 4 deletions
|
@ -42,7 +42,7 @@ class ConnectionController:
|
||||||
|
|
||||||
if profile.has_subscription():
|
if profile.has_subscription():
|
||||||
|
|
||||||
if profile.subscription.expires_at is None:
|
if not profile.subscription.has_been_activated():
|
||||||
ProfileController.activate_subscription(profile, connection_observer=connection_observer)
|
ProfileController.activate_subscription(profile, connection_observer=connection_observer)
|
||||||
|
|
||||||
proxy_configuration = ConnectionController.with_preferred_connection(profile.subscription.billing_code, task=WebServiceApiService.get_proxy_configuration, connection_observer=connection_observer)
|
proxy_configuration = ConnectionController.with_preferred_connection(profile.subscription.billing_code, task=WebServiceApiService.get_proxy_configuration, connection_observer=connection_observer)
|
||||||
|
@ -59,7 +59,7 @@ class ConnectionController:
|
||||||
|
|
||||||
if profile.has_subscription():
|
if profile.has_subscription():
|
||||||
|
|
||||||
if profile.subscription.expires_at is None:
|
if not profile.subscription.has_been_activated():
|
||||||
ProfileController.activate_subscription(profile, connection_observer=connection_observer)
|
ProfileController.activate_subscription(profile, connection_observer=connection_observer)
|
||||||
|
|
||||||
wireguard_configuration = ConnectionController.with_preferred_connection(profile.location.code, profile.subscription.billing_code, task=WebServiceApiService.post_wireguard_session, connection_observer=connection_observer)
|
wireguard_configuration = ConnectionController.with_preferred_connection(profile.location.code, profile.subscription.billing_code, task=WebServiceApiService.post_wireguard_session, connection_observer=connection_observer)
|
||||||
|
|
|
@ -168,7 +168,9 @@ class ProfileController:
|
||||||
|
|
||||||
if profile.is_system_profile():
|
if profile.is_system_profile():
|
||||||
|
|
||||||
if SystemStateController.get() is not None:
|
system_state = SystemStateController.get()
|
||||||
|
|
||||||
|
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:
|
else:
|
||||||
|
|
|
@ -21,8 +21,11 @@ class Subscription:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def has_been_activated(self):
|
||||||
|
return self.expires_at is not None
|
||||||
|
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
return self.expires_at is not None and self.expires_at > datetime.now(timezone.utc)
|
return self.has_been_activated() and self.expires_at > datetime.now(timezone.utc)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_iso_format(datetime_string: str):
|
def from_iso_format(datetime_string: str):
|
||||||
|
|
Loading…
Reference in a new issue