diff --git a/core/controllers/base.py b/core/controllers/base.py index a7bc629a0e0b..31f7c7ca211e 100644 --- a/core/controllers/base.py +++ b/core/controllers/base.py @@ -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 diff --git a/core/controllers/home.py b/core/controllers/home.py index 922fcac22c80..6e2ee4b79566 100644 --- a/core/controllers/home.py +++ b/core/controllers/home.py @@ -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.""" @@ -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.""" @@ -320,4 +320,3 @@ def post(self): else: raise self.InvalidInputException( 'This server does not allow file uploads.') ->>>>>>> develop diff --git a/core/controllers/home_test.py b/core/controllers/home_test.py index d5b4d27f7662..ff9651b3359b 100644 --- a/core/controllers/home_test.py +++ b/core/controllers/home_test.py @@ -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.""" @@ -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() @@ -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): @@ -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) @@ -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): @@ -346,4 +335,3 @@ def test_exploration_upload_button(self): response.mustcontain('ng-click="showUploadExplorationModal()"') self.logout() ->>>>>>> develop diff --git a/core/controllers/library.py b/core/controllers/library.py index 81cf26d433fe..54b965e9ffab 100644 --- a/core/controllers/library.py +++ b/core/controllers/library.py @@ -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({ diff --git a/core/controllers/library_test.py b/core/controllers/library_test.py index f9bd23909fdd..5b6522530e79 100644 --- a/core/controllers/library_test.py +++ b/core/controllers/library_test.py @@ -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.""" @@ -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): diff --git a/core/controllers/profile.py b/core/controllers/profile.py index 8321151ded60..dcdc4947ae16 100644 --- a/core/controllers/profile.py +++ b/core/controllers/profile.py @@ -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) diff --git a/core/templates/dev/head/app.js b/core/templates/dev/head/app.js index 389982ff59d9..834e828f774d 100644 --- a/core/templates/dev/head/app.js +++ b/core/templates/dev/head/app.js @@ -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 || []) : [])); @@ -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' @@ -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); @@ -130,7 +96,6 @@ oppia.config([ warningMessage = rejection.data.error; } alertsService.addWarning(warningMessage); ->>>>>>> develop } return $q.reject(rejection); } diff --git a/core/templates/dev/head/base.html b/core/templates/dev/head/base.html index 2a52fccea313..fd9fd200fad0 100644 --- a/core/templates/dev/head/base.html +++ b/core/templates/dev/head/base.html @@ -25,11 +25,7 @@
{% block content %}{% endblock %} -<<<<<<< HEAD - -======= {% block footer %}{% endblock %} ->>>>>>> develop
{%- endmacro %} @@ -60,7 +56,7 @@ -<<<<<<< HEAD + - -======= - {% block subtitle %}{% endblock %} - {% block maintitle %}Oppia{% endblock %} {% block base_url %}{% endblock base_url %} ->>>>>>> develop + {% block header_css %} {% include 'header_css_libs.html' %} {% endblock header_css %} @@ -180,12 +173,9 @@ {% endif %} -<<<<<<< HEAD -