forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates voiceover admin page (oppia#19561)
* Creates voiceover model * Adds test for entity voiceover model * Add voiceover domain and service methods. * Adds voiceover domain and services tests * Fixes mypy checks * Creates voiceover policy model * Fixes linter issues. * Address review comments * Adds regex check for language accent code * Updates voiceover policy model name. * Adds voiceover language accent constants * Adds language accent codes list for voiceovers * updates docstring * updates docstring * Creates voiceover admin page structure. * Deletes voice policy dir and shifts it into voiceover dir * Adds helper methods to get & save in VoiceoverAutogenerationPolicyModel * Adds navbar in the voiceover admin page. * Creates json files to stores L-a constants. * Adds test to validate voiceover language accent constants. * Removes dead code * Creates voiceover admin backend api service * Updates code comment * Updates code comment * Adds voiceover admin controller tests. * Adds fronetend tests. * Updates Readme. * Fixes lint checks * Adds voicover admin component methods. * Adds language codes saving functionality * Adds frontend tests. * Adds CSS * Adds CSS * Fixes backend and lint checks * Adds backend test * Adds frontend tests * Fixes typescript checks * Adds confirmation modal and updates saving workflow. * Updates UI * Updates CSS * Updates css * Updates html alignment * Updates dropdown css * Updates test description
- Loading branch information
Showing
30 changed files
with
1,919 additions
and
8 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Copyright 2024 The Oppia Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS-IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Controllers for the voiceover admin page.""" | ||
|
||
from __future__ import annotations | ||
|
||
from core import feconf | ||
from core.controllers import acl_decorators | ||
from core.controllers import base | ||
from core.domain import voiceover_services | ||
|
||
from typing import Dict, TypedDict | ||
|
||
|
||
class VoiceoverAdminPage(base.BaseHandler[Dict[str, str], Dict[str, str]]): | ||
"""Renders the voiceover admin page.""" | ||
|
||
URL_PATH_ARGS_SCHEMAS: Dict[str, str] = {} | ||
HANDLER_ARGS_SCHEMAS: Dict[str, Dict[str, str]] = {'GET': {}} | ||
|
||
@acl_decorators.can_access_voiceover_admin_page | ||
def get(self) -> None: | ||
"""Renders the voiceover admin page.""" | ||
self.render_template('voiceover-admin-page.mainpage.html') | ||
|
||
|
||
class VoiceoverAdminDataHandler( | ||
base.BaseHandler[Dict[str, str], Dict[str, str]] | ||
): | ||
"""Fetches relevant data for the voiceover admin page.""" | ||
|
||
GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON | ||
URL_PATH_ARGS_SCHEMAS: Dict[str, str] = {} | ||
HANDLER_ARGS_SCHEMAS: Dict[str, Dict[str, str]] = {'GET': {}} | ||
|
||
@acl_decorators.can_access_voiceover_admin_page | ||
def get(self) -> None: | ||
"""Retrieves relevant data for the voiceover admin page.""" | ||
|
||
language_accent_master_list: Dict[str, Dict[str, str]] = ( | ||
voiceover_services.get_language_accent_master_list()) | ||
|
||
language_codes_mapping: Dict[str, Dict[str, bool]] = ( | ||
voiceover_services.get_all_language_accent_codes_for_voiceovers()) | ||
self.values.update({ | ||
'language_accent_master_list': | ||
language_accent_master_list, | ||
'language_codes_mapping': language_codes_mapping | ||
}) | ||
self.render_json(self.values) | ||
|
||
|
||
class PutLanguageCodesHandlerNormalizedPayloadDict(TypedDict): | ||
"""Dict representation of VoiceoverLanguageCodesMappingHandler's | ||
normalized_request dictionary. | ||
""" | ||
|
||
language_codes_mapping: Dict[str, Dict[str, bool]] | ||
|
||
|
||
class VoiceoverLanguageCodesMappingHandler( | ||
base.BaseHandler[ | ||
PutLanguageCodesHandlerNormalizedPayloadDict, | ||
Dict[str, str] | ||
] | ||
): | ||
"""Updates the language codes mapping field in the backend.""" | ||
|
||
GET_HANDLER_ERROR_RETURN_TYPE = feconf.HANDLER_TYPE_JSON | ||
URL_PATH_ARGS_SCHEMAS: Dict[str, str] = {} | ||
HANDLER_ARGS_SCHEMAS = { | ||
'PUT': { | ||
'language_codes_mapping': { | ||
'schema': { | ||
'type': 'variable_keys_dict', | ||
'keys': { | ||
'schema': { | ||
'type': 'basestring' | ||
} | ||
}, | ||
'values': { | ||
'schema': { | ||
'type': 'variable_keys_dict', | ||
'keys': { | ||
'schema': { | ||
'type': 'basestring' | ||
} | ||
}, | ||
'values': { | ||
'schema': { | ||
'type': 'bool' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@acl_decorators.can_access_voiceover_admin_page | ||
def put(self) -> None: | ||
"""Updates the language codes mapping for the Oppia supported | ||
voiceovers. | ||
""" | ||
assert self.normalized_payload is not None | ||
language_codes_mapping = ( | ||
self.normalized_payload['language_codes_mapping']) | ||
|
||
voiceover_services.save_language_accent_support( | ||
language_codes_mapping) | ||
self.render_json(self.values) |
Oops, something went wrong.