Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

l #1

Merged
merged 2 commits into from
Aug 28, 2024
Merged

l #1

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions kolibri/core/content/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,17 @@
from kolibri.core.device.models import ContentCacheKey
from kolibri.core.discovery.utils.network.client import NetworkClient
from kolibri.core.discovery.utils.network.errors import NetworkLocationConnectionFailure
from kolibri.core.discovery.utils.network.errors import NetworkLocationNotFound
from kolibri.core.discovery.utils.network.errors import NetworkLocationResponseFailure
from kolibri.core.discovery.utils.network.errors import ResourceGoneError
from kolibri.core.discovery.well_known import CENTRAL_CONTENT_BASE_URL
from kolibri.core.lessons.models import Lesson
from kolibri.core.logger.models import ContentSessionLog
from kolibri.core.logger.models import ContentSummaryLog
from kolibri.core.query import SQSum
from kolibri.core.utils.pagination import ValuesViewsetCursorPagination
from kolibri.core.utils.pagination import ValuesViewsetLimitOffsetPagination
from kolibri.core.utils.pagination import ValuesViewsetPageNumberPagination
from kolibri.utils import conf
from kolibri.utils.conf import OPTIONS
from kolibri.utils.urls import validator

Expand Down Expand Up @@ -1884,12 +1885,15 @@ def retrieve(self, request, pk=None):
@no_cache_on_method
def kolibri_studio_status(self, request, **kwargs):
try:
baseurl = conf.OPTIONS["Urls"]["CENTRAL_CONTENT_BASE_URL"]
client = NetworkClient.build_for_address(baseurl)
client = NetworkClient.build_for_address(CENTRAL_CONTENT_BASE_URL)
resp = client.get("/api/public/info")
data = resp.json()
data["available"] = True
data["status"] = "online"
return Response(data)
except (NetworkLocationResponseFailure, NetworkLocationConnectionFailure):
except (
NetworkLocationResponseFailure,
NetworkLocationConnectionFailure,
NetworkLocationNotFound,
):
return Response({"status": "offline", "available": False})
Loading