From 1a604cf94b7d50b966ea64ec51b84a59f04a7669 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Fri, 5 Feb 2016 00:34:13 +0100 Subject: [PATCH 1/4] refactor khan channel images and use setting instead of json data --- .../distributed/custom_context_processors.py | 17 +---------------- .../static}/images/horizontal-logo-small.png | Bin .../static}/images/learning-image.png | Bin .../static}/images/logo_10_enlarged_2.png | Bin .../templates/distributed/base.html | 2 +- .../templates/distributed/homepage.html | 2 +- kalite/settings/base.py | 13 +++++++++++++ 7 files changed, 16 insertions(+), 18 deletions(-) rename {data/khan => kalite/distributed/static}/images/horizontal-logo-small.png (100%) rename {data/khan => kalite/distributed/static}/images/learning-image.png (100%) rename {data/khan => kalite/distributed/static}/images/logo_10_enlarged_2.png (100%) diff --git a/kalite/distributed/custom_context_processors.py b/kalite/distributed/custom_context_processors.py index 035b165dde..0a989e34e8 100644 --- a/kalite/distributed/custom_context_processors.py +++ b/kalite/distributed/custom_context_processors.py @@ -5,32 +5,17 @@ * Metadata about the central server (for syncing, getting content, language packs, etc) * App settings, including version / build ID """ -import json -import os - from django.conf import settings from django.utils.translation import ugettext as _ from kalite import version from kalite.topic_tools import settings as topic_tools_settings -channel_data = {} def custom(request): - global channel_data channel_data_trans = {} - - # MUST: Translation must happen inside this function because it will NOT work if it is outside - # because that part of the code only runs once when this module is loaded/imported. - if not channel_data: - # Parsing a whole JSON file just to load the settings is not nice - try: - channel_data = json.load(open(os.path.join(topic_tools_settings.CHANNEL_DATA_PATH, "channel_data.json"), 'r')) - except IOError: - channel_data = {} - - for key, value in channel_data.items(): + for key, value in settings.KALITE_CHANNEL_CONTEXT_DATA.items(): channel_data_trans[key] = _(value) return { diff --git a/data/khan/images/horizontal-logo-small.png b/kalite/distributed/static/images/horizontal-logo-small.png similarity index 100% rename from data/khan/images/horizontal-logo-small.png rename to kalite/distributed/static/images/horizontal-logo-small.png diff --git a/data/khan/images/learning-image.png b/kalite/distributed/static/images/learning-image.png similarity index 100% rename from data/khan/images/learning-image.png rename to kalite/distributed/static/images/learning-image.png diff --git a/data/khan/images/logo_10_enlarged_2.png b/kalite/distributed/static/images/logo_10_enlarged_2.png similarity index 100% rename from data/khan/images/logo_10_enlarged_2.png rename to kalite/distributed/static/images/logo_10_enlarged_2.png diff --git a/kalite/distributed/templates/distributed/base.html b/kalite/distributed/templates/distributed/base.html index 0c9914dcd2..38543285a1 100644 --- a/kalite/distributed/templates/distributed/base.html +++ b/kalite/distributed/templates/distributed/base.html @@ -97,7 +97,7 @@ diff --git a/kalite/distributed/templates/distributed/homepage.html b/kalite/distributed/templates/distributed/homepage.html index 10e93d6657..0a5925364c 100644 --- a/kalite/distributed/templates/distributed/homepage.html +++ b/kalite/distributed/templates/distributed/homepage.html @@ -29,7 +29,7 @@

{% trans "Learn!" %}

- {% trans 'Learn with Khan Academy videos and exercises!' %} + {% trans 'Learn with Khan Academy videos and exercises!' %}
diff --git a/kalite/settings/base.py b/kalite/settings/base.py index 7d4e59a4ea..9ca9a45e75 100644 --- a/kalite/settings/base.py +++ b/kalite/settings/base.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import time from kalite import version import logging @@ -247,6 +248,18 @@ STATIC_URL = getattr(local_settings, "STATIC_URL", "/static/") +# Context data included by ka lite's context processor +KALITE_CHANNEL_CONTEXT_DATA = { + "channel_name": u"KA Lite", + "head_line": u"A free world-class education for anyone anywhere.", + "tag_line": u"KA Lite is a light-weight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection.", + "channel_license": u"CC-BY-NC-SA", + "footer_text": u"Videos © 2015 Khan Academy (Creative Commons) // Exercises © 2015 Khan Academy", + "header_logo": os.path.join(STATIC_URL, 'images', 'horizontal-logo-small.png'), + "frontpage_splash": os.path.join(STATIC_URL, 'images', 'logo_10_enlarged_2.png'), +} + + DEFAULT_DATABASE_PATH = getattr(local_settings, "DATABASE_PATH", DEFAULT_DATABASE_PATH) DATABASES = getattr(local_settings, "DATABASES", { From 6f4ea2048f41d417581f802f2b6aed8ec4a89b67 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Fri, 5 Feb 2016 00:34:25 +0100 Subject: [PATCH 2/4] remove unused image --- .../static/images/learning-image.png | Bin 11076 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 kalite/distributed/static/images/learning-image.png diff --git a/kalite/distributed/static/images/learning-image.png b/kalite/distributed/static/images/learning-image.png deleted file mode 100755 index 1039fc61e0aa75c2b5bef50e80ef315219742111..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11076 zcmV-KE4$Q*P)E+&CqNvKUl>{zrnk5VL@8|C4*zM}%1~e@C`TF_!_`Tm*@8QGv`TFne z>8qrgq@9-h`SbYm>iGHlh@sAq!IibGp_<3g`uX?!`uLocjApgv`NwGK?D8>`z{S?} zsKWFUhtbH}tG(Cx`un=h=#GVY0~b1mlAh`F`%`WkNC*T4 z9Tnj0_wMoc^Z5K)R7_P|V*2jZ@2q>Gu*LZL{wX*TdTn9;rwn0cZ2)!AkdTl6{`v0q z{A6ERhlz<383-IF4*KM|i?8xeQ&#={G&oBe=UNAOcz0`F;(b3VZuCBS?_RP%8NJmKc`1z)%sI#=R*4Ebj`}oJl#<{w>4h#&W z)9&2d+`z!VI5;=~0u$lk;UFL&EG#Vk{{HCb=o1qY^YioY@bCo%1m@=E>+9?4>gxLX z`t|ko?(XjS`T6+x_y7O^cI(OT001d}Nklpt-h> zkL`u#Y}F5~SulhauVWh@wzEzlw0FYy#BX}M9*%bYKHyf7phcGv9G@vMge4H9ZZZs6 zAuZb^b;so7qHb_atw!s%z}W&x(t^x2IYE;dvgw#LQ5M7^!w@cMm^EHwNQ09#zEqJ7 zQZK;a7!nLTL2w*Ws8wKlpz{Jlx`eEeHG!}=*%skjhnBX5lFaFPsl;0{5jb#st0|L~ zX_Bu0Cjm!)QB+DoidOMxu~sY^41TT99L{>yN~Fe>Y8A0o66x>__?qCBib4R#G%KZ=CRgZU#pK}_@LdT!-!$k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:00:00 2001 From: Benjamin Bach Date: Fri, 5 Feb 2016 00:46:28 +0100 Subject: [PATCH 3/4] refactor the way channel meta data is translated --- kalite/distributed/custom_context_processors.py | 7 +------ kalite/settings/base.py | 11 ++++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/kalite/distributed/custom_context_processors.py b/kalite/distributed/custom_context_processors.py index 0a989e34e8..e624e0e738 100644 --- a/kalite/distributed/custom_context_processors.py +++ b/kalite/distributed/custom_context_processors.py @@ -6,7 +6,6 @@ * App settings, including version / build ID """ from django.conf import settings -from django.utils.translation import ugettext as _ from kalite import version from kalite.topic_tools import settings as topic_tools_settings @@ -14,16 +13,12 @@ def custom(request): - channel_data_trans = {} - for key, value in settings.KALITE_CHANNEL_CONTEXT_DATA.items(): - channel_data_trans[key] = _(value) - return { "central_server_host": settings.CENTRAL_SERVER_HOST, "central_server_domain": settings.CENTRAL_SERVER_DOMAIN, "securesync_protocol": settings.SECURESYNC_PROTOCOL, "base_template": "distributed/base.html", - "channel_data": channel_data_trans, + "channel_data": settings.KALITE_CHANNEL_CONTEXT_DATA, "channel": topic_tools_settings.CHANNEL, "is_central": False, "settings": settings, diff --git a/kalite/settings/base.py b/kalite/settings/base.py index 9ca9a45e75..b9ad1f8fb5 100644 --- a/kalite/settings/base.py +++ b/kalite/settings/base.py @@ -9,6 +9,7 @@ from kalite import ROOT_DATA_PATH from kalite.shared.warnings import RemovedInKALite_v016_Warning +from django.utils.translation import ugettext_lazy # Load local settings first... loading it again later to have the possibility # to overwrite default app settings.. very strange method, will be refactored @@ -250,11 +251,11 @@ # Context data included by ka lite's context processor KALITE_CHANNEL_CONTEXT_DATA = { - "channel_name": u"KA Lite", - "head_line": u"A free world-class education for anyone anywhere.", - "tag_line": u"KA Lite is a light-weight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection.", - "channel_license": u"CC-BY-NC-SA", - "footer_text": u"Videos © 2015 Khan Academy (Creative Commons) // Exercises © 2015 Khan Academy", + "channel_name": ugettext_lazy(u"KA Lite"), + "head_line": ugettext_lazy(u"A free world-class education for anyone anywhere."), + "tag_line": ugettext_lazy(u"KA Lite is a light-weight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection."), + "channel_license": ugettext_lazy(u"CC-BY-NC-SA"), + "footer_text": ugettext_lazy(u"Videos © 2015 Khan Academy (Creative Commons) // Exercises © 2015 Khan Academy"), "header_logo": os.path.join(STATIC_URL, 'images', 'horizontal-logo-small.png'), "frontpage_splash": os.path.join(STATIC_URL, 'images', 'logo_10_enlarged_2.png'), } From b42d920cf1b73fb2cd4667770c57c719538e62b2 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Fri, 5 Feb 2016 18:11:51 +0100 Subject: [PATCH 4/4] Annotate content db after unpacking assessment zip - fixes #4815 --- .../commands/unpack_assessment_zip.py | 19 +++++++++---------- .../commands/annotate_content_items.py | 5 ----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/kalite/contentload/management/commands/unpack_assessment_zip.py b/kalite/contentload/management/commands/unpack_assessment_zip.py index 8ce59d9f90..4c9e1cc1d5 100644 --- a/kalite/contentload/management/commands/unpack_assessment_zip.py +++ b/kalite/contentload/management/commands/unpack_assessment_zip.py @@ -11,6 +11,7 @@ from django.conf import settings as django_settings from django.core.management.base import BaseCommand, CommandError +from django.core.management import call_command logging = django_settings.LOG @@ -39,17 +40,17 @@ def handle(self, *args, **kwargs): return if is_valid_url(ziplocation): # url; download the zip - print "Downloading assessment item data from a remote server. Please be patient; this file is big, so this may take some time..." + logging.info("Downloading assessment item data from a remote server. Please be patient; this file is big, so this may take some time...") # this way we can download stuff larger than the device's RAM r = requests.get(ziplocation, prefetch=False) content_length = r.headers.get("Content-Length") - print "Downloaded size: ", str(int(content_length) // 1024 // 1024) + " MB" if content_length else "Unknown" + logging.info("Downloaded size: ", str(int(content_length) // 1024 // 1024) + " MB" if content_length else "Unknown") sys.stdout.write("Downloading file...") sys.stdout.flush() f = tempfile.TemporaryFile("r+") r.raise_for_status() for cnt, chunk in enumerate(r.iter_content(chunk_size=1024)): - if chunk: # filter out keep-alive new chunks + if chunk: # filter out keep-alive new chunks f.write(chunk) if cnt % 1000 == 0: sys.stdout.write(".") @@ -60,10 +61,14 @@ def handle(self, *args, **kwargs): else: # file; just open it normally f = open(ziplocation, "rb") - print "Unpacking..." + logging.info("Unpacking...") zf = zipfile.ZipFile(f, "r") unpack_zipfile_to_content_folder(zf) + logging.info("Scanning items and updating content db...") + call_command("annotate_content_items") + logging.info("Done, assessment items installed and everything updated. Refresh your browser!") + def should_upgrade_assessment_items(): # if assessmentitems.version doesn't exist, then we assume @@ -101,12 +106,6 @@ def unpack_zipfile_to_content_folder(zf): os.path.join(folder, 'assessmentitems.version'), settings.KHAN_ASSESSMENT_ITEM_VERSION_PATH ) - # JSON file is apparrently not required (not in the test at least) - if os.path.isfile(os.path.join(folder, 'assessmentitems.json')): - shutil.move( - os.path.join(folder, 'assessmentitems.json'), - settings.KHAN_ASSESSMENT_ITEM_JSON_PATH - ) def is_valid_url(url): diff --git a/kalite/topic_tools/management/commands/annotate_content_items.py b/kalite/topic_tools/management/commands/annotate_content_items.py index a99545da37..18b2413739 100644 --- a/kalite/topic_tools/management/commands/annotate_content_items.py +++ b/kalite/topic_tools/management/commands/annotate_content_items.py @@ -1,6 +1,3 @@ -import os - -from django.core.management import call_command from optparse import make_option from django.conf import settings as django_settings @@ -12,8 +9,6 @@ from django.core.management.base import BaseCommand -from django.utils.translation import gettext as _ - class Command(BaseCommand):