Skip to content

Commit

Permalink
I18N: solving conflicts from merge with develop. (#1899)
Browse files Browse the repository at this point in the history
* BROKEN. Solving conflicts from merge with develop. Test not passing.

* Fixing frontend tests.

* Fixing backend tests

* Correcting comments from PR

* Integration tests fixes
  • Loading branch information
mit0110 authored and seanlip committed Jun 1, 2016
1 parent 045b5bd commit 1552bda
Show file tree
Hide file tree
Showing 50 changed files with 350 additions and 856 deletions.
2 changes: 1 addition & 1 deletion core/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def render_template(
self.user_id, self.PAGE_NAME_FOR_CSRF)
values['csrf_token_for_footer'] = (
CsrfTokenManager.create_csrf_token(
self.user_id, feconf.CSRF_PAGE_NAME_FOOTER))
self.user_id, feconf.FOOTER_PAGE_NAME_FOR_CSRF))

self.response.cache_control.no_cache = True
self.response.cache_control.must_revalidate = True
Expand Down
7 changes: 3 additions & 4 deletions core/controllers/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,10 @@ def get(self):
})


<<<<<<< HEAD
class SiteLanguageHandler(base.BaseHandler):
"""Changes the preferred system language in the user's preferences."""

PAGE_NAME_FOR_CSRF = feconf.CSRF_PAGE_NAME_FOOTER
PAGE_NAME_FOR_CSRF = feconf.FOOTER_PAGE_NAME_FOR_CSRF

def put(self):
"""Handles PUT requests."""
Expand All @@ -231,7 +230,8 @@ def put(self):
user_services.update_preferred_site_language_code(
self.user_id, site_language_code)
self.render_json({})
=======


class NewExploration(base.BaseHandler):
"""Creates a new exploration."""

Expand Down Expand Up @@ -320,4 +320,3 @@ def post(self):
else:
raise self.InvalidInputException(
'This server does not allow file uploads.')
>>>>>>> develop
28 changes: 8 additions & 20 deletions core/controllers/home_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ class HomePageTest(test_utils.GenericTestBase):
def test_logged_out_homepage(self):
"""Test the logged-out version of the home page."""
response = self.testapp.get('/')
<<<<<<< HEAD
self.assertEqual(response.status_int, 200)
response.mustcontain(
'I18N_GALLERY_PAGE_TITLE', 'I18N_SIDEBAR_HOME_ABOUT',
'I18N_TOPNAV_SIGN_IN', no=['I18N_TOPNAV_LOGOUT'])
=======

self.assertEqual(response.status_int, 302)
self.assertIn('splash', response.headers['location'])
response.follow().mustcontain(
'Oppia - Home', 'About', 'Sign in', no=['Logout'])
>>>>>>> develop
'I18N_LIBRARY_PAGE_TITLE', 'I18N_SIDEBAR_ABOUT_LINK',
'I18N_TOPNAV_SIGN_IN', no=['I18N_TOPNAV_LOGOUT'])

def test_notifications_dashboard_redirects_for_logged_out_users(self):
"""Test the logged-out view of the notifications dashboard."""
Expand Down Expand Up @@ -67,12 +62,7 @@ def test_logged_in_notifications_dashboard(self):
response.mustcontain(
'I18N_TOPNAV_NOTIFICATIONS', 'I18N_TOPNAV_LOGOUT',
self.get_expected_logout_url('/'),
<<<<<<< HEAD
no=['>I18N_TOPNAV_SIGN_IN<', self.get_expected_login_url('/')])
=======
no=['Sign in', 'Your personal tutor',
self.get_expected_login_url('/')])
>>>>>>> develop
self.logout()


Expand Down Expand Up @@ -273,7 +263,6 @@ def test_author_ids_are_handled_correctly(self):
self.assertNotIn('author_id', response['recent_notifications'][0])


<<<<<<< HEAD
class SiteLanguageHandlerTests(test_utils.GenericTestBase):

def test_save_site_language_handler(self):
Expand All @@ -282,10 +271,9 @@ def test_save_site_language_handler(self):
self.signup(self.EDITOR_EMAIL, self.EDITOR_USERNAME)
language_code = 'es'
self.login(self.EDITOR_EMAIL)
response = self.testapp.get(feconf.GALLERY_URL)
response = self.testapp.get('/preferences')
self.assertEqual(response.status_int, 200)
csrf_token = self.get_csrf_token_from_response(response,
for_footer=True)
csrf_token = self.get_csrf_token_from_response(response)
self.put_json(feconf.SITE_LANGUAGE_DATA_URL, {
'site_language_code': language_code,
}, csrf_token)
Expand All @@ -299,14 +287,15 @@ def test_save_site_language_handler(self):

def test_save_site_language_no_user(self):
"""The SiteLanguageHandler handler can be called without a user."""
response = self.testapp.get(feconf.GALLERY_URL)
response = self.testapp.get(feconf.LIBRARY_INDEX_URL)
self.assertEqual(response.status_int, 200)
csrf_token = self.get_csrf_token_from_response(response,
for_footer=True)
self.put_json(feconf.SITE_LANGUAGE_DATA_URL, {
'site_language_code': 'es',
}, csrf_token)
=======


class CreationButtonsTest(test_utils.GenericTestBase):

def setUp(self):
Expand Down Expand Up @@ -346,4 +335,3 @@ def test_exploration_upload_button(self):
response.mustcontain('ng-click="showUploadExplorationModal()"')

self.logout()
>>>>>>> develop
2 changes: 2 additions & 0 deletions core/controllers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class LibraryPage(base.BaseHandler):
for search results.
"""

PAGE_NAME_FOR_CSRF = 'library'

def get(self):
"""Handles GET requests."""
self.values.update({
Expand Down
43 changes: 1 addition & 42 deletions core/controllers/library_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ def test_library_page(self):
"""Test access to the library page."""
response = self.testapp.get(feconf.LIBRARY_INDEX_URL)
self.assertEqual(response.status_int, 200)
<<<<<<< HEAD:core/controllers/galleries_test.py
response.mustcontain('I18N_GALLERY_PAGE_TITLE', 'CATEGORIES')
=======
response.mustcontain('Library', 'Categories')
>>>>>>> develop:core/controllers/library_test.py
response.mustcontain('I18N_LIBRARY_PAGE_TITLE', 'CATEGORIES')

def test_library_handler_demo_exploration(self):
"""Test the library data handler on demo explorations."""
Expand Down Expand Up @@ -190,43 +186,6 @@ def test_library_handler_for_created_explorations(self):
'status': rights_manager.ACTIVITY_STATUS_PUBLICIZED,
}, response_dict['explorations_list'][0])

<<<<<<< HEAD:core/controllers/galleries_test.py
def test_new_exploration_ids(self):
"""Test generation of exploration ids."""
self.login(self.EDITOR_EMAIL)

response = self.testapp.get(feconf.GALLERY_URL)
self.assertEqual(response.status_int, 200)
csrf_token = self.get_csrf_token_from_response(response)
exp_a_id = self.post_json(feconf.NEW_EXPLORATION_URL, {
'title': self.UNICODE_TEST_STRING,
'category': self.UNICODE_TEST_STRING,
'objective': 'Learn how to generate exploration ids.',
'language_code': feconf.DEFAULT_LANGUAGE_CODE
}, csrf_token)[galleries.EXPLORATION_ID_KEY]
self.assertEqual(len(exp_a_id), 12)

self.logout()

def test_exploration_upload_button(self):
"""Test that the exploration upload button appears when appropriate."""
self.login(self.EDITOR_EMAIL)

response = self.testapp.get(feconf.GALLERY_URL)
self.assertEqual(response.status_int, 200)
response.mustcontain(no=['I18N_GALLERY_UPLOAD_EXPLORATION'])

config_services.set_property(
feconf.SYSTEM_COMMITTER_ID, 'allow_yaml_file_upload', True)

response = self.testapp.get(feconf.GALLERY_URL)
self.assertEqual(response.status_int, 200)
response.mustcontain('I18N_GALLERY_UPLOAD_EXPLORATION')

self.logout()

=======
>>>>>>> develop:core/controllers/library_test.py

class CategoryConfigTest(test_utils.GenericTestBase):

Expand Down
5 changes: 0 additions & 5 deletions core/controllers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,10 @@ def get(self):
'profile_picture_data_url': user_settings.profile_picture_data_url,
'user_bio': user_settings.user_bio,
'subject_interests': user_settings.subject_interests,
<<<<<<< HEAD
'can_receive_email_updates': user_services.get_email_preferences(
self.user_id)['can_receive_email_updates']
=======
'can_receive_email_updates': (
user_email_preferences['can_receive_email_updates']),
'can_receive_editor_role_email': (
user_email_preferences['can_receive_editor_role_email'])
>>>>>>> develop
})
self.render_json(self.values)

Expand Down
53 changes: 9 additions & 44 deletions core/templates/dev/head/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@
// in order to make the testing and production environments match.
var oppia = angular.module(
'oppia', [
<<<<<<< HEAD
'ngMaterial', 'ngAnimate', 'ngSanitize', 'ngResource', 'ui.bootstrap',
'ui.sortable', 'infinite-scroll', 'ngJoyRide', 'ngImgCrop', 'ui.validate',
'textAngular', 'pascalprecht.translate', 'ngCookies'
=======
'ngMaterial', 'ngAnimate', 'ngSanitize', 'ngTouch', 'ngResource',
'ui.bootstrap', 'ui.sortable', 'infinite-scroll', 'ngJoyRide', 'ngImgCrop',
'ui.validate', 'textAngular', 'toastr'
>>>>>>> develop
'ui.validate', 'textAngular', 'pascalprecht.translate', 'ngCookies',
'toastr'
].concat(
window.GLOBALS ? (window.GLOBALS.ADDITIONAL_ANGULAR_MODULES || [])
: []));
Expand All @@ -56,41 +51,6 @@ oppia.config([
$locationProvider.html5Mode(true);
}

<<<<<<< HEAD
$httpProvider.interceptors.push([
'$q', '$log', 'warningsData', function($q, $log, warningsData) {
return {
request: function(config) {
// If this request carries data (in the form of a JS object),
// JSON-stringify it and store it under 'payload'.
var csrfToken = '';
if (config.data) {
if (config.requestIsFromFooter) {
csrfToken = GLOBALS.csrf_token_for_footer;
} else {
csrfToken = GLOBALS.csrf_token;
}
config.data = $.param({
csrf_token: csrfToken,
payload: JSON.stringify(config.data),
source: document.URL
}, true);
}
return config;
},
responseError: function(rejection) {
// A rejection status of -1 seems to indicate (it's hard to find
// documentation) that the response has not completed,
// which can occur if the user navigates away from the page
// while the response is pending, This should not be considered
// an error.
if (rejection.status !== -1) {
$log.error(rejection.data);

var warningMessage = 'Error communicating with server.';
if (rejection.data && rejection.data.error) {
warningMessage = rejection.data.error;
=======
// Set default headers for POST and PUT requests.
$httpProvider.defaults.headers.post = {
'Content-Type': 'application/x-www-form-urlencoded'
Expand All @@ -107,9 +67,15 @@ oppia.config([
request: function(config) {
// If this request carries data (in the form of a JS object),
// JSON-stringify it and store it under 'payload'.
var csrfToken = '';
if (config.data) {
if (config.requestIsFromFooter) {
csrfToken = GLOBALS.csrf_token_for_footer;
} else {
csrfToken = GLOBALS.csrf_token;
}
config.data = $.param({
csrf_token: GLOBALS.csrf_token,
csrf_token: csrfToken,
payload: JSON.stringify(config.data),
source: document.URL
}, true);
Expand All @@ -130,7 +96,6 @@ oppia.config([
warningMessage = rejection.data.error;
}
alertsService.addWarning(warningMessage);
>>>>>>> develop
}
return $q.reject(rejection);
}
Expand Down
30 changes: 5 additions & 25 deletions core/templates/dev/head/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
</div>
<div ng-show="!loadingMessage">
{% block content %}{% endblock %}
<<<<<<< HEAD

=======
{% block footer %}{% endblock %}
>>>>>>> develop
</div>
</div>
{%- endmacro %}
Expand Down Expand Up @@ -60,19 +56,16 @@
<meta property="og:image" content="{{DOMAIN_URL}}/images/logo/288x288_logo_mint.png">

<link rel="apple-touch-icon" href="/images/logo/favicon.png">
<<<<<<< HEAD

<!-- The title is bound to the rootScope. The content of the block
maintitle can be a string or a translation id. If it is a translation it
will be replaced by its translation when the page is loading. If it is a
string it would be displayed as is. This is the only way to translate
the page title because the head of the file is outside the scope of
any other controller. -->
<title itemprop="name" translate="{% block maintitle %}Oppia{% endblock maintitle %}"></title>

=======
<title itemprop="name">{% block subtitle %}{% endblock %} - {% block maintitle %}Oppia{% endblock %}</title>
{% block base_url %}{% endblock base_url %}
>>>>>>> develop

{% block header_css %}
{% include 'header_css_libs.html' %}
{% endblock header_css %}
Expand Down Expand Up @@ -180,12 +173,9 @@
{% endif %}
</div>
</a>
<<<<<<< HEAD

<ul class="dropdown-menu ng-cloak oppia-navbar-profile-dropdown" role="menu" ng-mouseover="onMouseoverProfilePictureOrDropdown($event)" ng-mouseleave="onMouseoutProfilePictureOrDropdown($event)" ng-show="profileDropdownIsActive">
=======
<ul class="dropdown-menu ng-cloak oppia-navbar-dropdown" role="menu" ng-mouseover="onMouseoverProfilePictureOrDropdown($event)" ng-mouseleave="onMouseoutProfilePictureOrDropdown($event)" ng-show="profileDropdownIsActive">
>>>>>>> develop

<li>
<a ng-click="onMouseoutProfilePictureOrDropdown($event)" href="/profile/{{username}}">
<strong>{{username}}</strong>
Expand Down Expand Up @@ -235,22 +225,14 @@
</li>
{% else %}
<li class="dropdown oppia-clickable-dropdown pull-right">
<<<<<<< HEAD
<a href="{{login_url}}" class="oppia-navbar-profile-dropdown-toggle" style="font-size: 1em; padding-top: 17px;">
<span translate="I18N_TOPNAV_SIGN_IN"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu oppia-navbar-profile-dropdown" role="menu" style="padding: 0;" ng-mouseover="onMouseoverDropdownMenu($event)" ng-mouseleave="onMouseoutDropdownMenu($event)">
=======
<div class="oppia-navbar-button-container" style="margin-right: 10px;">
<button class="btn oppia-navbar-button"
ng-click="onLoginButtonClicked('{{login_url}}')">
<span>Sign in</span>
<span translate="I18N_TOPNAV_SIGN_IN"></span>
<span class="caret"></span>
</button>
</div>
<ul class="dropdown-menu oppia-navbar-dropdown" role="menu" style="margin-right: 15px; padding: 0;" ng-mouseover="onMouseoverDropdownMenu($event)" ng-mouseleave="onMouseoutDropdownMenu($event)">
>>>>>>> develop
<li>
<a href style="padding: 0; width: 200px;" ng-click="onLoginButtonClicked('{{login_url}}')">
<img src="/images/signin/Red-signin-Long-base-44dp.png">
Expand Down Expand Up @@ -315,8 +297,6 @@

{{ warnings_and_loader() }}
</div>
<<<<<<< HEAD
=======

<noscript>
<div class="oppia-page-cards-container">
Expand All @@ -328,7 +308,7 @@ <h2>We Need JavaScript in Your Browser <i class="material-icons">&#xE811;</i></h
</div>
</noscript>

>>>>>>> develop

{% include 'side_nav.html' %}

</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{% extends "base.html" %}

{% block maintitle %}
Oppia Editor
{{ title }} - Oppia Editor
{% endblock maintitle %}

{% block subtitle %}
{{ title }}
{% endblock subtitle %}

{% block header_js %}
{{ super() }}
<script type="text/javascript">
Expand Down
Loading

0 comments on commit 1552bda

Please sign in to comment.