Exemplo n.º 1
0
def update_content_metadata(channel_id, node_ids=None, exclude_node_ids=None):
    set_leaf_node_availability_from_local_file_availability(
        channel_id, node_ids=node_ids, exclude_node_ids=exclude_node_ids
    )
    recurse_annotation_up_tree(channel_id)
    calculate_channel_fields(channel_id)
    ContentCacheKey.update_cache_key()
Exemplo n.º 2
0
def set_availability(channel_id, checksums=None):
    if checksums is None:
        set_local_file_availability_from_disk()
    else:
        mark_local_files_as_available(checksums)

    set_leaf_node_availability_from_local_file_availability(channel_id)
    recurse_availability_up_tree(channel_id)
    ContentCacheKey.update_cache_key()
Exemplo n.º 3
0
 def plugin_data(self):
     return {
         "contentCacheKey": ContentCacheKey.get_cache_key(),
         "languageGlobals": self.language_globals(),
         "oidcProviderEnabled": OIDCProviderHook().is_enabled,
         "kolibriTheme": ThemeHook().theme,
     }
Exemplo n.º 4
0
def kolibri_content_cache_key():
    js = """
    <script>
      var contentCacheKey = '{cache_key}';
    </script>
    """.format(cache_key=ContentCacheKey.get_cache_key(), )
    return mark_safe(js)
Exemplo n.º 5
0
 def post(self, request, *args, **kwargs):
     try:
         ids = request.data
         assert isinstance(ids, list)
         assert all(map(validate_uuid, ids))
     except AssertionError:
         raise ParseError("Array of ids not sent in body of request")
     queryset = ChannelMetadata.objects.filter(root__available=True)
     total_channels = queryset.count()
     if len(ids) != total_channels:
         raise ParseError("Expected {} ids, but only received {}".format(
             total_channels, len(ids)))
     if queryset.filter_by_uuids(ids).count() != len(ids):
         raise ParseError(
             "List of ids does not match the available channels on the server"
         )
     queryset.update(order=Case(*(When(id=uuid, then=i + 1)
                                  for i, uuid in enumerate(ids))))
     ContentCacheKey.update_cache_key()
     return Response({})
Exemplo n.º 6
0
 def plugin_data(self):
     language_code = get_language()
     static_root = static("assets/fonts/noto-full")
     full_file = "{}.{}.{}.css?v={}"
     return {
         "fullCSSFileModern": full_file.format(
             static_root, language_code, "modern", kolibri.__version__
         ),
         "fullCSSFileBasic": full_file.format(
             static_root, language_code, "basic", kolibri.__version__
         ),
         "allowRemoteAccess": allow_other_browsers_to_connect()
         or not interface.enabled,
         "appCapabilities": interface.capabilities,
         "contentCacheKey": ContentCacheKey.get_cache_key(),
         "languageGlobals": self.language_globals(),
         "oidcProviderEnabled": OIDCProviderHook.is_enabled(),
         "kolibriTheme": ThemeHook.get_theme(),
     }
Exemplo n.º 7
0
 def plugin_data(self):
     language_code = get_language()
     static_root = static("assets/fonts/noto-full")
     full_file = "{}.{}.{}.css?v={}"
     return {
         "fullCSSFileModern":
         full_file.format(static_root, language_code, "modern",
                          kolibri.__version__),
         "fullCSSFileBasic":
         full_file.format(static_root, language_code, "basic",
                          kolibri.__version__),
         "contentCacheKey":
         ContentCacheKey.get_cache_key(),
         "languageGlobals":
         self.language_globals(),
         "oidcProviderEnabled":
         OIDCProviderHook.is_enabled(),
         "kolibriTheme":
         ThemeHook.get_theme(),
     }
Exemplo n.º 8
0
def set_content_invisible(channel_id, node_ids, exclude_node_ids):
    set_leaf_nodes_invisible(channel_id, node_ids, exclude_node_ids)
    recurse_annotation_up_tree(channel_id)
    set_channel_metadata_fields(channel_id)
    ContentCacheKey.update_cache_key()
Exemplo n.º 9
0
def get_cache_key(*args, **kwargs):
    return str(ContentCacheKey.get_cache_key())
Exemplo n.º 10
0
def calculate_spa_etag(*args, **kwargs):
    return hashlib.md5(
        kolibri_version.encode("utf-8")
        + str(ContentCacheKey.get_cache_key()).encode("utf-8")
        + str(ThemeHook.cacheKey()).encode("utf-8")
    ).hexdigest()
Exemplo n.º 11
0
 def delete_content_tree_and_files(self):
     # Use Django ORM to ensure cascading delete:
     self.root.delete()
     ContentCacheKey.update_cache_key()
Exemplo n.º 12
0
def create_content_cache_key(apps, schema_editor):
    from kolibri.core.device.models import ContentCacheKey

    ContentCacheKey.update_cache_key()