From bcf861edee5660cec7bc930b4decad59bf8f0c5d Mon Sep 17 00:00:00 2001 From: Ali-Salman29 Date: Wed, 10 Jul 2024 19:17:09 +0200 Subject: [PATCH 1/2] update: default lang to Arabic and fix certificate fonts --- .../certificates/sass/_sdaia-template.scss | 6 +++--- .../sdaia_features/course_progress/apps.py | 1 + .../course_progress/settings/common.py | 1 + .../course_progress/settings/production.py | 11 +++++++++++ .../sdaia_features/course_progress/signals.py | 18 ++++++++++++++++-- 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 openedx/features/sdaia_features/course_progress/settings/production.py diff --git a/lms/static/certificates/sass/_sdaia-template.scss b/lms/static/certificates/sass/_sdaia-template.scss index b32fd6a7e454..10b7e9da87d2 100644 --- a/lms/static/certificates/sass/_sdaia-template.scss +++ b/lms/static/certificates/sass/_sdaia-template.scss @@ -131,7 +131,7 @@ html { flex-direction: column; } &__personName { - font-size: 22px; + font-size: 30px; } &__subTitleBody, &__personWrap, @@ -187,7 +187,7 @@ html { font-size: 18px; } &__personName { - font-size: 20px; + font-size: 26px; } } @@ -262,7 +262,7 @@ html { gap: 5px; } &__personName { - font-size: 18px; + font-size: 22px; } } } diff --git a/openedx/features/sdaia_features/course_progress/apps.py b/openedx/features/sdaia_features/course_progress/apps.py index 7f9a6ed4ee13..8170f0af275f 100644 --- a/openedx/features/sdaia_features/course_progress/apps.py +++ b/openedx/features/sdaia_features/course_progress/apps.py @@ -21,6 +21,7 @@ class CourseProgressConfig(AppConfig): PluginSettings.CONFIG: { ProjectType.LMS: { SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: "settings.common"}, + SettingsType.PRODUCTION: {PluginSettings.RELATIVE_PATH: "settings.production"}, } }, } diff --git a/openedx/features/sdaia_features/course_progress/settings/common.py b/openedx/features/sdaia_features/course_progress/settings/common.py index 6f9ead3f8fe7..aabc3ea22e2a 100644 --- a/openedx/features/sdaia_features/course_progress/settings/common.py +++ b/openedx/features/sdaia_features/course_progress/settings/common.py @@ -6,3 +6,4 @@ def plugin_settings(settings): """ Required Common settings """ + settings.SDAIA_DEFAULT_LANGUAGE_CODE = 'ar' diff --git a/openedx/features/sdaia_features/course_progress/settings/production.py b/openedx/features/sdaia_features/course_progress/settings/production.py new file mode 100644 index 000000000000..0cc3c142cc3a --- /dev/null +++ b/openedx/features/sdaia_features/course_progress/settings/production.py @@ -0,0 +1,11 @@ + +"""Settings""" + + +def plugin_settings(settings): + """ + Required Common settings + """ + settings.SDAIA_DEFAULT_LANGUAGE_CODE = settings.ENV_TOKENS.get( + 'SDAIA_DEFAULT_LANGUAGE_CODE', settings.SDAIA_DEFAULT_LANGUAGE_CODE + ) diff --git a/openedx/features/sdaia_features/course_progress/signals.py b/openedx/features/sdaia_features/course_progress/signals.py index f24eb6c87db9..b376b9f628b7 100644 --- a/openedx/features/sdaia_features/course_progress/signals.py +++ b/openedx/features/sdaia_features/course_progress/signals.py @@ -8,7 +8,11 @@ from django.dispatch import receiver from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.contrib.sites.models import Site +from django.conf import settings +from openedx.core.djangoapps.user_api.preferences import api as preferences_api +from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY +from openedx.core.djangoapps.user_authn.views.register import REGISTER_USER from openedx.core.djangoapps.signals.signals import COURSE_GRADE_NOW_PASSED from openedx.core.lib.celery.task_utils import emulate_http_request from openedx.features.sdaia_features.course_progress.models import CourseCompletionEmailHistory @@ -41,7 +45,7 @@ def send_course_progress_milestones_achievement_emails(**kwargs): try: course_completion_percentages_for_emails = [int(entry.strip()) for entry in course_completion_percentages_for_emails] except Exception as e: - log.info(f"invalid course_completion_percentages_for_emails for course {str(course_key)}") + logger.info(f"invalid course_completion_percentages_for_emails for course {str(course_key)}") return user_id = instance.user_id @@ -70,4 +74,14 @@ def send_course_completion_email(sender, user, course_id, **kwargs): # pylint: Listen for a signal indicating that the user has passed a course run. """ logger.info(f"\n\n\n inside send_course_completion_email \n\n\n") - send_user_course_completion_email.delay(user.id, str(course_id)) \ No newline at end of file + send_user_course_completion_email.delay(user.id, str(course_id)) + + + +@receiver(REGISTER_USER) +def update_account_preference(sender, user, registration, **kwargs): + """ + SDAIA: Update the user preference language to "SDAIA_DEFAULT_LANGUAGE_CODE" on a account creation + """ + if not preferences_api.get_user_preference(user, LANGUAGE_KEY) == settings.SDAIA_DEFAULT_LANGUAGE_CODE: + preferences_api.set_user_preference(user, LANGUAGE_KEY, settings.SDAIA_DEFAULT_LANGUAGE_CODE) From 4adc715b35c7a0459773b77a8ac98f181f847605 Mon Sep 17 00:00:00 2001 From: Ali-Salman29 Date: Thu, 11 Jul 2024 09:29:35 +0200 Subject: [PATCH 2/2] fix: spacing --- openedx/features/sdaia_features/course_progress/signals.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openedx/features/sdaia_features/course_progress/signals.py b/openedx/features/sdaia_features/course_progress/signals.py index b376b9f628b7..148e571df597 100644 --- a/openedx/features/sdaia_features/course_progress/signals.py +++ b/openedx/features/sdaia_features/course_progress/signals.py @@ -77,7 +77,6 @@ def send_course_completion_email(sender, user, course_id, **kwargs): # pylint: send_user_course_completion_email.delay(user.id, str(course_id)) - @receiver(REGISTER_USER) def update_account_preference(sender, user, registration, **kwargs): """