From 2998a2e9b72c0fc461d83ac20ec73699f8624a91 Mon Sep 17 00:00:00 2001 From: Carson Gee Date: Wed, 23 Apr 2014 17:27:29 -0400 Subject: [PATCH] Code review changes i18n --- .../test/acceptance/pages/lms/staff_view.py | 15 +----- .../js/spec/staff_debug_actions_spec.js | 2 +- lms/static/js/staff_debug_actions.js | 52 ++++++++++++++----- lms/templates/staff_problem_info.html | 10 ++-- 4 files changed, 48 insertions(+), 31 deletions(-) diff --git a/common/test/acceptance/pages/lms/staff_view.py b/common/test/acceptance/pages/lms/staff_view.py index ef755339e6..7ebe14434d 100644 --- a/common/test/acceptance/pages/lms/staff_view.py +++ b/common/test/acceptance/pages/lms/staff_view.py @@ -49,17 +49,6 @@ class StaffDebugPage(PageObject): def is_browser_on_page(self): return self.q(css='section.staff-modal').present - def _click_link(self, link_text): - """ - Clicks on an action link based on text - """ - for link in self.q(css='section.staff-modal a').execute(): - if link.text == link_text: - return link.click() - - raise Exception('Could not find the {} link to click on.'.format( - link_text)) - def reset_attempts(self, user=None): """ This clicks on the reset attempts link with an optionally @@ -67,7 +56,7 @@ class StaffDebugPage(PageObject): """ if user: self.q(css='input[id^=sd_fu_]').first.fill(user) - self._click_link('Reset Student Attempts') + self.q(css='section.staff-modal a#staff-debug-reset').click() def delete_state(self, user=None): """ @@ -75,7 +64,7 @@ class StaffDebugPage(PageObject): """ if user: self.q(css='input[id^=sd_fu_]').fill(user) - self._click_link('Delete Student State') + self.q(css='section.staff-modal a#staff-debug-sdelete').click() @property def idash_msg(self): diff --git a/lms/static/js/spec/staff_debug_actions_spec.js b/lms/static/js/spec/staff_debug_actions_spec.js index f1a175e1c4..5e8041e0ef 100644 --- a/lms/static/js/spec/staff_debug_actions_spec.js +++ b/lms/static/js/spec/staff_debug_actions_spec.js @@ -1,7 +1,7 @@ describe('StaffDebugActions', function() { var loc = 'test_loc'; var fixture_id = 'sd_fu_' + loc; - var fixture = $(''); + var fixture = $('', { id: fixture_id, placeholder: "userman" }); describe('get_url ', function() { it('defines url to courseware ajax entry point', function() { diff --git a/lms/static/js/staff_debug_actions.js b/lms/static/js/staff_debug_actions.js index dcdf500cc2..c749109790 100644 --- a/lms/static/js/staff_debug_actions.js +++ b/lms/static/js/staff_debug_actions.js @@ -1,3 +1,4 @@ +// Build StaffDebug object var StaffDebug = (function(){ get_current_url = function() { @@ -6,7 +7,6 @@ var StaffDebug = (function(){ get_url = function(action){ var pathname = this.get_current_url(); - console.log(pathname) var url = pathname.substr(0,pathname.indexOf('/courseware')) + '/' + action; return url; } @@ -20,10 +20,12 @@ var StaffDebug = (function(){ } do_idash_action = function(locname, idaction){ - var pdata = {'action': idaction, - 'problem_for_student': locname, - 'unique_student_identifier': get_user(locname) - } + var pdata = { + 'action': idaction, + 'problem_for_student': locname, + 'unique_student_identifier': get_user(locname) + } + $.ajax({ type: "POST", url: get_url('instructor'), @@ -33,7 +35,18 @@ var StaffDebug = (function(){ $("#result_" + locname).html( msg ); }, error: function(request, status, error) { - $("#result_" + locname).html('

' + gettext('Something has gone wrong with this request. The server replied with a status of: ') + error + '

'); + var text = _.template( + gettext('Something has gone wrong with this request. \ + The server replied with a status of: {error}'), + {error: error}, + {interpolate: /\{(.+?)\}/g} + ) + var html = _.template( + '

{text}

', + {text: text}, + {interpolate: /\{(.+?)\}/g} + ) + $("#result_"+locname).html(html); }, dataType: 'html' }); @@ -47,11 +60,24 @@ var StaffDebug = (function(){ do_idash_action(locname, "Delete student state for module"); } - return {reset: reset, - sdelete: sdelete, - do_idash_action: do_idash_action, - get_current_url: get_current_url, - get_url: get_url, - get_user: get_user - } + return { + reset: reset, + sdelete: sdelete, + do_idash_action: do_idash_action, + get_current_url: get_current_url, + get_url: get_url, + get_user: get_user + } })(); + +// Register click handlers +$(document).ready(function() { + $('#staff-debug-reset').click(function() { + StaffDebug.reset($(this).data('location')); + return false; + }); + $('#staff-debug-sdelete').click(function() { + StaffDebug.sdelete($(this).data('location')); + return false; + }); +}); diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index fd075e8e25..03032a4976 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -55,14 +55,16 @@ ${block_content}
-

Actions

+

${_('Actions')}

- +
- [ ${_('Reset Student Attempts')} | - ${_('Delete Student State')} + [ + ${_('Reset Student Attempts')} + | + ${_('Delete Student State')} ]