Skip to content

Commit

Permalink
Remove regressions from bad rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaoming committed Oct 12, 2015
1 parent c91c646 commit 8b64b39
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
11 changes: 7 additions & 4 deletions kalite/distributed/features/steps/content_rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from securesync.models import Device

from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait


RATING_CONTAINER_ID = "rating-container"
TEXT_CONTAINER_ID = "text-container"
Expand Down Expand Up @@ -167,16 +169,17 @@ def rate_id(context, id_, val=3):
:return: nothing
"""

def get_rating_el(driver):
def rate_element(driver):
try:
container = find_id_with_wait(context, id_)
els = container.find_elements_by_class_name(STAR_RATING_OPTION_CLASS)
return [el for el in els if int(el.get_attribute("data-val")) == val].pop()
rating_el = [el for el in els if int(el.get_attribute("data-val")) == val].pop()
rating_el.click()
return True
except (NoSuchElementException, StaleElementReferenceException):
return False

rating_el = WebDriverWait(context.browser, 10).until(get_rating_el)
rating_el.click()
WebDriverWait(context.browser, 10).until(rate_element)


def enter_text_feedback(context, text_feedback):
Expand Down
16 changes: 9 additions & 7 deletions kalite/distributed/static/js/distributed/rating/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ module.exports = BaseView.extend({
Then once the user has filled out the rating completely, call renderAll to allow review/editing.
*/
this.$el.html(this.template());
this.$(".rating-delete").hide();

this.star_view_quality = this.add_subview(StarView, {title: gettext("Quality"), el: this.$("#star-container-quality"), model: this.model, rating_attr: "quality", label_values: this.quality_label_values});

var self = this;

var callback = function() {
self.star_view_difficulty = self.add_subview(StarView, {title: gettext("Difficulty"), el: self.$("#star-container-difficulty"), model: self.model, rating_attr: "difficulty", label_values: this.difficulty_label_values});
self.$(".rating-delete").show();
};
// If the "quality" is already set, display "difficulty" immediately. Otherwise wait.
if (parseInt(this.model.get("quality")) === 0) {
this.listenToOnce(this.model, "change:quality", function(){
self.star_view_difficulty = self.add_subview(StarView, {title: gettext("Difficulty"), el: self.$("#star-container-difficulty"), model: self.model, rating_attr: "difficulty", label_values: this.difficulty_label_values});
});
if (!this.model.get("quality") || parseInt(this.model.get("quality")) === 0) {
this.listenToOnce(this.model, "change:quality", callback);
} else {
self.star_view_difficulty = self.add_subview(StarView, {title: gettext("Difficulty"), el: self.$("#star-container-difficulty"), model: self.model, rating_attr: "difficulty", label_values: this.difficulty_label_values});
callback();
}

this.listenToOnce(this.model, "change:difficulty", this.renderAll);
Expand Down Expand Up @@ -165,7 +167,7 @@ var StarView = BaseView.extend({
var val = $(target).attr("data-val");
this.model.set(this.rating_attr, val);
this.model.debounced_save();
}, 500, true),
}, 100, true),

mouse_enter_callback: function(ev) {
// The target event could be either the .star-rating-option or a child element, so whatever the case get the
Expand Down
23 changes: 9 additions & 14 deletions kalite/updates/management/commands/languagepackdownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def handle(self, *args, **options):
raise

def cb(self, percent):
self.update_stage(stage_percent=percent/100.)
self.update_stage(stage_percent=percent / 100.)

def get_language_pack(lang_code, software_version, callback):
"""Download language pack for specified language"""
Expand All @@ -133,13 +133,14 @@ def unpack_language(lang_code, zip_filepath=None, zip_fp=None, zip_data=None):
logging.info("Unpacking new translations")
ensure_dir(get_po_filepath(lang_code=lang_code))

## Unpack into temp dir
# # Unpack into temp dir
try:
z = zipfile.ZipFile(zip_fp or (zip_data and StringIO(zip_data)) or open(zip_filepath, "rb"))
except zipfile.BadZipfile as e:
# Need to add more information on the error message.
# Need to add more information on the errror message.
# See http://stackoverflow.com/questions/6062576/adding-information-to-a-python-exception
raise type(e), type(e)(e.message + _("Language pack corrupted. Please try downloading the language pack again in a few minutes."))
z.extractall(os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code))

def move_dubbed_video_map(lang_code):
lang_pack_location = os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code)
Expand All @@ -159,17 +160,11 @@ def move_dubbed_video_map(lang_code):
logging.error("Error removing dubbed video directory (%s): %s" % (dubbed_video_dir, e))

def move_video_sizes_file(lang_code):
lang_pack_location = os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code)
filename = os.path.basename(REMOTE_VIDEO_SIZE_FILEPATH)
src_path = os.path.join(lang_pack_location, filename)
dest_path = REMOTE_VIDEO_SIZE_FILEPATH

# replace the old remote_video_size json
if not os.path.exists(src_path):
logging.error("Could not find videos sizes file (%s)" % src_path)
else:
logging.debug('Moving %s to %s' % (src_path, dest_path))
shutil.move(src_path, dest_path)
"""
This is no longer needed. See:
https://github.com/learningequality/ka-lite/issues/4538#issuecomment-144560505
"""
return

def move_exercises(lang_code):
lang_pack_location = os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code)
Expand Down
5 changes: 4 additions & 1 deletion kalitectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
# Match all patterns of "--option value" and fail if they exist
__validate_cmd_options = re.compile(r"--?[^\s]+\s+(?:(?!--|-[\w]))")
if __validate_cmd_options.search(" ".join(sys.argv[1:])):
sys.stderr.write("Please only use --option=value or -x123 patterns. No spaces allowed between option and value. The option parser gets confused if you do otherwise.\n\nWill be fixed for next version 0.16")
sys.stderr.write("Please only use --option=value or -x123 patterns. No spaces allowed between option and value. The option parser gets confused if you do otherwise.\n\nWill be fixed for next version 0.15")
sys.exit(1)

from threading import Thread
Expand Down Expand Up @@ -569,6 +569,8 @@ def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler=
except KeyboardInterrupt:
# Handled in cherrypy by waiting for all threads to join
pass
except SystemExit:
print("KA Lite caught system exit signal, quitting.")

print("FINISHED serving HTTP")

Expand All @@ -579,6 +581,7 @@ def start(debug=False, watch=False, daemonize=True, args=[], skip_job_scheduler=
from fle_utils.chronograph.management.commands import cronserver_blocking
cronserver_blocking.shutdown = True
cron_thread.join()
print("Job scheduler terminated.")


def stop(args=[], sys_exit=True):
Expand Down

0 comments on commit 8b64b39

Please sign in to comment.