46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
from core.models.ClientVersion import ClientVersion
|
|
from core.services.WebServiceApiService import WebServiceApiService
|
|
from typing import Optional
|
|
|
|
|
|
class ClientVersionController:
|
|
|
|
@staticmethod
|
|
def get_latest():
|
|
return ClientVersion.latest()
|
|
|
|
@staticmethod
|
|
def is_latest(client_version):
|
|
|
|
latest_client_version = ClientVersion.latest()
|
|
|
|
if latest_client_version is None:
|
|
return True
|
|
|
|
return client_version.version_number == latest_client_version.version_number
|
|
|
|
@staticmethod
|
|
def get(version_number: str):
|
|
return ClientVersion.find(version_number)
|
|
|
|
@staticmethod
|
|
def get_or_new(version_number: str):
|
|
|
|
client_version = ClientVersionController.get(version_number)
|
|
|
|
if client_version is None:
|
|
return ClientVersion(version_number)
|
|
|
|
return client_version
|
|
|
|
@staticmethod
|
|
def get_all():
|
|
return ClientVersion.all()
|
|
|
|
@staticmethod
|
|
def _sync(proxies: Optional[dict] = None):
|
|
|
|
client_versions = WebServiceApiService.get_client_versions(proxies)
|
|
|
|
ClientVersion.truncate()
|
|
ClientVersion.save_many(client_versions)
|