Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [AXM-475] refactor firebase settings #2560

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lms/djangoapps/mobile_api/notifications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..decorators import mobile_view


@mobile_view(is_user=True)
@mobile_view()
class GCMDeviceViewSet(GCMDeviceViewSetBase):
"""
**Use Case**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}You have been invited to be a beta tester for {{ course_name }} at {{ site_name }} by a member of the course staff.{% endblocktrans %}
{% blocktrans %}You have been invited to be a beta tester for {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear student,{% endblocktrans %}
{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }} by a member of the course staff.{% endblocktrans %}
{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }}.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear Student,{% endblocktrans %}
{% blocktrans %}You have been unenrolled from the course {{ course_name }} by a member of the course staff. Please disregard the invitation previously sent.{% endblocktrans %}
{% blocktrans %}You have been unenrolled from the course {{ course_name }}. Please disregard the invitation previously sent.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}You have been unenrolled from {{ course_name }} at {{ site_name }} by a member of the course staff. This course will no longer appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% blocktrans %}You have been unenrolled from {{ course_name }} at {{ site_name }}. This course will no longer appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }} by a member of the course staff. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }}. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Dear {{ full_name }}{% endblocktrans %}
{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }} by a member of the course staff. This course will remain on your dashboard, but you will no longer be part of the beta testing group.{% endblocktrans %}
{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }}. This course will remain on your dashboard, but you will no longer be part of the beta testing group.{% endblocktrans %}
{% endautoescape %}
43 changes: 20 additions & 23 deletions openedx/core/djangoapps/ace_common/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,24 @@ def plugin_settings(settings): # lint-amnesty, pylint: disable=missing-function
settings.FEATURES['test_django_plugin'] = True
settings.FCM_APP_NAME = 'fcm-edx-platform'

if getattr(settings, 'FIREBASE_SETUP_STATUS', None) is None:
settings.ACE_CHANNEL_DEFAULT_PUSH = 'push_notification'

# Note: To local development with Firebase, you must set FIREBASE_CREDENTIALS.
settings.FCM_APP_NAME = 'fcm-edx-platform'
settings.FIREBASE_CREDENTIALS = None

if firebase_app := setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME):
settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH)
settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH)

settings.PUSH_NOTIFICATIONS_SETTINGS = {
'CONFIG': 'push_notifications.conf.AppConfig',
'APPLICATIONS': {
settings.FCM_APP_NAME: {
'PLATFORM': 'FCM',
'FIREBASE_APP': firebase_app,
},
settings.ACE_CHANNEL_DEFAULT_PUSH = 'push_notification'
# Note: To local development with Firebase, you must set FIREBASE_CREDENTIALS.
settings.FCM_APP_NAME = 'fcm-edx-platform'
settings.FIREBASE_CREDENTIALS = None

settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME)

if getattr(settings, 'FIREBASE_APP', None):
settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH)
settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH)

settings.PUSH_NOTIFICATIONS_SETTINGS = {
'CONFIG': 'push_notifications.conf.AppConfig',
'APPLICATIONS': {
settings.FCM_APP_NAME: {
'PLATFORM': 'FCM',
'FIREBASE_APP': settings.FIREBASE_APP,
},
'UPDATE_ON_DUPLICATE_REG_ID': True,
}
settings.FIREBASE_SETUP_STATUS = True
else:
settings.FIREBASE_SETUP_STATUS = False
},
'UPDATE_ON_DUPLICATE_REG_ID': True,
}
33 changes: 15 additions & 18 deletions openedx/core/djangoapps/ace_common/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,21 @@ def plugin_settings(settings):
settings.ACE_CHANNEL_TRANSACTIONAL_EMAIL = settings.ENV_TOKENS.get(
'ACE_CHANNEL_TRANSACTIONAL_EMAIL', settings.ACE_CHANNEL_TRANSACTIONAL_EMAIL
)
settings.FCM_APP_NAME = settings.ENV_TOKENS.get('FCM_APP_NAME', 'fcm-edx-platform')
settings.FIREBASE_CREDENTIALS = settings.ENV_TOKENS.get('FIREBASE_CREDENTIALS', {})
settings.FCM_APP_NAME = settings.ENV_TOKENS.get('FCM_APP_NAME', settings.FCM_APP_NAME)
settings.FIREBASE_CREDENTIALS = settings.ENV_TOKENS.get('FIREBASE_CREDENTIALS', settings.FIREBASE_CREDENTIALS)

if getattr(settings, 'FIREBASE_SETUP_STATUS', None) is None:
if firebase_app := setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME):
settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH)
settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH)
settings.FIREBASE_APP = setup_firebase_app(settings.FIREBASE_CREDENTIALS, settings.FCM_APP_NAME)
if settings.FIREBASE_APP:
settings.ACE_ENABLED_CHANNELS.append(settings.ACE_CHANNEL_DEFAULT_PUSH)
settings.ACE_ENABLED_POLICIES.append(settings.ACE_CHANNEL_DEFAULT_PUSH)

settings.PUSH_NOTIFICATIONS_SETTINGS = {
'CONFIG': 'push_notifications.conf.AppConfig',
'APPLICATIONS': {
settings.FCM_APP_NAME: {
'PLATFORM': 'FCM',
'FIREBASE_APP': firebase_app,
},
settings.PUSH_NOTIFICATIONS_SETTINGS = {
'CONFIG': 'push_notifications.conf.AppConfig',
'APPLICATIONS': {
settings.FCM_APP_NAME: {
'PLATFORM': 'FCM',
'FIREBASE_APP': settings.FIREBASE_APP,
},
'UPDATE_ON_DUPLICATE_REG_ID': True,
}
settings.FIREBASE_SETUP_STATUS = True
else:
settings.FIREBASE_SETUP_STATUS = False
},
'UPDATE_ON_DUPLICATE_REG_ID': True,
}
9 changes: 7 additions & 2 deletions openedx/core/djangoapps/ace_common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def setup_firebase_app(firebase_credentials, app_name='fcm-app'):
except ImportError:
log.error('Could not import firebase_admin package.')
return

if firebase_credentials:
certificate = firebase_admin.credentials.Certificate(firebase_credentials)
return firebase_admin.initialize_app(certificate, name=app_name)
try:
app = firebase_admin.get_app(app_name)
except ValueError:
certificate = firebase_admin.credentials.Certificate(firebase_credentials)
app = firebase_admin.initialize_app(certificate, name=app_name)
return app
5 changes: 3 additions & 2 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
-e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications
-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications
# via -r requirements/edx/github.in
-e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace
# via
Expand Down Expand Up @@ -567,7 +567,7 @@ fastavro==1.9.4
# via openedx-events
filelock==3.14.0
# via snowflake-connector-python
firebase-admin==5.0.0
firebase-admin==6.5.0
# via edx-ace
frozenlist==1.4.1
# via
Expand Down Expand Up @@ -946,6 +946,7 @@ pyjwt[crypto]==2.8.0
# edx-drf-extensions
# edx-proctoring
# edx-rest-api-client
# firebase-admin
# pylti1p3
# snowflake-connector-python
# social-auth-core
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ chardet==5.2.0
# via diff-cover
coverage==7.5.1
# via -r requirements/edx/coverage.in
diff-cover==9.0.0
diff-cover==7.7.0
# via -r requirements/edx/coverage.in
jinja2==3.1.4
# via diff-cover
Expand Down
7 changes: 4 additions & 3 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
-e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications
-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down Expand Up @@ -351,7 +351,7 @@ defusedxml==0.7.1
# ora2
# python3-openid
# social-auth-core
diff-cover==9.0.0
diff-cover==7.7.0
# via -r requirements/edx/testing.txt
dill==0.3.8
# via
Expand Down Expand Up @@ -926,7 +926,7 @@ filelock==3.14.0
# snowflake-connector-python
# tox
# virtualenv
firebase-admin==5.0.0
firebase-admin==6.5.0
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down Expand Up @@ -1651,6 +1651,7 @@ pyjwt[crypto]==2.8.0
# edx-drf-extensions
# edx-proctoring
# edx-rest-api-client
# firebase-admin
# pylti1p3
# snowflake-connector-python
# social-auth-core
Expand Down
5 changes: 3 additions & 2 deletions requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
-e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications
-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications
# via -r requirements/edx/base.txt
-e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace
# via -r requirements/edx/base.txt
Expand Down Expand Up @@ -653,7 +653,7 @@ filelock==3.14.0
# via
# -r requirements/edx/base.txt
# snowflake-connector-python
firebase-admin==5.0.0
firebase-admin==6.5.0
# via
# -r requirements/edx/base.txt
# edx-ace
Expand Down Expand Up @@ -1137,6 +1137,7 @@ pyjwt[crypto]==2.8.0
# edx-drf-extensions
# edx-proctoring
# edx-rest-api-client
# firebase-admin
# pylti1p3
# snowflake-connector-python
# social-auth-core
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/github.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@
-e git+https://github.com/anupdhabarde/edx-proctoring-proctortrack.git@31c6c9923a51c903ae83760ecbbac191363aa2a2#egg=edx_proctoring_proctortrack

-e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace
-e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications
-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications
7 changes: 4 additions & 3 deletions requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
-e git+https://github.com/jazzband/django-push-notifications.git@906fe52058bad36b6af2bb292fdb9292ccaa94e5#egg=django_push_notifications
-e git+https://github.com/jazzband/django-push-notifications.git@0f7918136b5e6a9aec83d6513aad5b0f12143a9f#egg=django_push_notifications
# via -r requirements/edx/base.txt
-e git+https://github.com/raccoongang/edx-ace.git@mob-develop#egg=edx_ace
# via -r requirements/edx/base.txt
Expand Down Expand Up @@ -267,7 +267,7 @@ defusedxml==0.7.1
# ora2
# python3-openid
# social-auth-core
diff-cover==9.0.0
diff-cover==7.7.0
# via -r requirements/edx/coverage.txt
dill==0.3.8
# via pylint
Expand Down Expand Up @@ -707,7 +707,7 @@ filelock==3.14.0
# snowflake-connector-python
# tox
# virtualenv
firebase-admin==5.0.0
firebase-admin==6.5.0
# via
# -r requirements/edx/base.txt
# edx-ace
Expand Down Expand Up @@ -1240,6 +1240,7 @@ pyjwt[crypto]==2.8.0
# edx-drf-extensions
# edx-proctoring
# edx-rest-api-client
# firebase-admin
# pylti1p3
# snowflake-connector-python
# social-auth-core
Expand Down
Loading