Merge pull request #16770 from edx/pacing/refactor-common-code
Move ACE Common code out of Schedules
This commit is contained in:
@@ -1118,6 +1118,7 @@ INSTALLED_APPS = [
|
||||
'openedx.core.djangoapps.waffle_utils',
|
||||
|
||||
# Dynamic schedules
|
||||
'openedx.core.djangoapps.ace_common.apps.AceCommonConfig',
|
||||
'openedx.core.djangoapps.schedules.apps.SchedulesConfig',
|
||||
|
||||
# DRF filters
|
||||
|
||||
@@ -20,7 +20,7 @@ from lms.djangoapps.django_comment_client.utils import permalink
|
||||
import lms.lib.comment_client as cc
|
||||
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.schedules.template_context import get_base_template_context
|
||||
from openedx.core.djangoapps.ace_common.template_context import get_base_template_context
|
||||
from openedx.core.lib.celery.task_utils import emulate_http_request
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'schedules/edx_ace/common/base_body.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_body.html' %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
|
||||
{% trans "View discussion" as course_cta_text %}
|
||||
{% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text course_cta_url=post_link%}
|
||||
{% include "ace_common/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text course_cta_url=post_link%}
|
||||
|
||||
{% block google_analytics_pixel %}
|
||||
<img src="{{ ga_tracking_pixel_url }}" alt="" role="presentation" aria-hidden="true" style="display: block;"/>
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% extends 'schedules/edx_ace/common/base_head.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_head.html' %}
|
||||
|
||||
@@ -21,7 +21,7 @@ from lms.djangoapps.discussion.config.waffle import waffle, FORUM_RESPONSE_NOTIF
|
||||
from lms.djangoapps.discussion.signals.handlers import ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY
|
||||
from lms.djangoapps.discussion.tasks import _should_send_message
|
||||
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
|
||||
from openedx.core.djangoapps.schedules.template_context import get_base_template_context
|
||||
from openedx.core.djangoapps.ace_common.template_context import get_base_template_context
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfigurationFactory
|
||||
from openedx.core.djangoapps.theming.middleware import CurrentSiteThemeMiddleware
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
|
||||
@@ -2331,6 +2331,7 @@ INSTALLED_APPS = [
|
||||
'database_fixups',
|
||||
|
||||
'openedx.core.djangoapps.waffle_utils',
|
||||
'openedx.core.djangoapps.ace_common.apps.AceCommonConfig',
|
||||
'openedx.core.djangoapps.schedules.apps.SchedulesConfig',
|
||||
|
||||
# Course Goals
|
||||
|
||||
5
openedx/core/djangoapps/ace_common/__init__.py
Normal file
5
openedx/core/djangoapps/ace_common/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
ace_common is a Django App that provides common utilities and templates
|
||||
for edx-platform applications that use ACE as their messaging framework.
|
||||
"""
|
||||
default_app_config = 'openedx.core.djangoapps.ace_common.apps.AceCommonConfig' # pylint: disable=invalid-name
|
||||
13
openedx/core/djangoapps/ace_common/apps.py
Normal file
13
openedx/core/djangoapps/ace_common/apps.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""
|
||||
Configuration for the ace_common Django app.
|
||||
"""
|
||||
from django.apps import AppConfig
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class AceCommonConfig(AppConfig):
|
||||
"""
|
||||
Configuration class for the ace_common Django app.
|
||||
"""
|
||||
name = 'openedx.core.djangoapps.ace_common'
|
||||
verbose_name = _('ACE Common')
|
||||
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Context dictionary for templates that use the ace_common base template.
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
@@ -6,13 +9,19 @@ from openedx.core.djangoapps.theming.helpers import get_config_value_from_site_o
|
||||
|
||||
|
||||
def get_base_template_context(site):
|
||||
"""Dict with entries needed for all templates that use the base template"""
|
||||
"""
|
||||
Dict with entries needed for all templates that use the base template.
|
||||
"""
|
||||
return {
|
||||
# Platform information
|
||||
'homepage_url': marketing_link('ROOT'),
|
||||
'dashboard_url': reverse('dashboard'),
|
||||
'template_revision': getattr(settings, 'EDX_PLATFORM_REVISION', None),
|
||||
'platform_name': get_config_value_from_site_or_settings('PLATFORM_NAME', site=site, site_config_name='platform_name'),
|
||||
'platform_name': get_config_value_from_site_or_settings(
|
||||
'PLATFORM_NAME',
|
||||
site=site,
|
||||
site_config_name='platform_name',
|
||||
),
|
||||
'contact_mailing_address': get_config_value_from_site_or_settings(
|
||||
'CONTACT_MAILING_ADDRESS', site=site, site_config_name='contact_mailing_address'),
|
||||
'social_media_urls': get_config_value_from_site_or_settings('SOCIAL_MEDIA_FOOTER_URLS', site=site),
|
||||
@@ -1,13 +1,14 @@
|
||||
from urlparse import urlparse, parse_qs
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import urlparse
|
||||
|
||||
from crum import get_current_request
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from openedx.core.djangoapps.schedules.tracking import CampaignTrackingInfo, GoogleAnalyticsTrackingPixel
|
||||
from openedx.core.djangoapps.ace_common.tracking import CampaignTrackingInfo, GoogleAnalyticsTrackingPixel
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
register = template.Library()
|
||||
register = template.Library() # pylint: disable=invalid-name
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
@@ -133,7 +134,7 @@ def modify_url_to_track_clicks(url, campaign=None):
|
||||
if campaign is None:
|
||||
campaign = CampaignTrackingInfo()
|
||||
modified_url = parsed_url._replace(query=campaign.to_query_string(parsed_url.query))
|
||||
return modified_url.geturl()
|
||||
return modified_url.geturl() # pylint: disable=no-member
|
||||
|
||||
|
||||
def ensure_url_is_absolute(site, relative_path):
|
||||
@@ -1,3 +1,4 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import parse_qs, urlparse
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# pylint: disable=missing-docstring,no-member
|
||||
import uuid
|
||||
|
||||
from django.http import HttpRequest
|
||||
@@ -6,13 +7,13 @@ from django.test import override_settings
|
||||
from mock import patch
|
||||
|
||||
from edx_ace import Message, Recipient
|
||||
from openedx.core.djangoapps.schedules.templatetags.ace import (
|
||||
from openedx.core.djangoapps.ace_common.templatetags.ace import (
|
||||
ensure_url_is_absolute,
|
||||
with_link_tracking,
|
||||
google_analytics_tracking_pixel,
|
||||
_get_google_analytics_tracking_url
|
||||
)
|
||||
from openedx.core.djangoapps.schedules.tests.mixins import QueryStringAssertionMixin
|
||||
from openedx.core.djangoapps.ace_common.tests.mixins import QueryStringAssertionMixin
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
|
||||
from student.tests.factories import UserFactory
|
||||
@@ -23,6 +24,7 @@ class TestAbsoluteUrl(CacheIsolationTestCase):
|
||||
def setUp(self):
|
||||
self.site = SiteFactory.create()
|
||||
self.site.domain = 'example.com'
|
||||
super(TestAbsoluteUrl, self).setUp()
|
||||
|
||||
def test_absolute_url(self):
|
||||
absolute = ensure_url_is_absolute(self.site, '/foo/bar')
|
||||
@@ -41,7 +43,7 @@ class TestAbsoluteUrl(CacheIsolationTestCase):
|
||||
class EmailTemplateTagMixin(object):
|
||||
|
||||
def setUp(self):
|
||||
patcher = patch('openedx.core.djangoapps.schedules.templatetags.ace.get_current_request')
|
||||
patcher = patch('openedx.core.djangoapps.ace_common.templatetags.ace.get_current_request')
|
||||
self.mock_get_current_request = patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# pylint: disable=missing-docstring,no-member
|
||||
from unittest import TestCase
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
from openedx.core.djangoapps.schedules.tests.mixins import QueryStringAssertionMixin
|
||||
from openedx.core.djangoapps.schedules.tracking import (
|
||||
from openedx.core.djangoapps.ace_common.tests.mixins import QueryStringAssertionMixin
|
||||
from openedx.core.djangoapps.ace_common.tracking import (
|
||||
CampaignTrackingInfo,
|
||||
DEFAULT_CAMPAIGN_SOURCE,
|
||||
DEFAULT_CAMPAIGN_MEDIUM,
|
||||
@@ -1,3 +1,4 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import parse_qs
|
||||
|
||||
import attr
|
||||
@@ -92,7 +93,10 @@ class GoogleAnalyticsTrackingPixel(object):
|
||||
|
||||
parameters['tid'] = tracking_id
|
||||
|
||||
user_id_dimension = get_config_value_from_site_or_settings("GOOGLE_ANALYTICS_USER_ID_CUSTOM_DIMENSION", site=self.site)
|
||||
user_id_dimension = get_config_value_from_site_or_settings(
|
||||
"GOOGLE_ANALYTICS_USER_ID_CUSTOM_DIMENSION",
|
||||
site=self.site,
|
||||
)
|
||||
if user_id_dimension is not None and self.user_id is not None:
|
||||
parameter_name = 'cd{0}'.format(user_id_dimension)
|
||||
parameters[parameter_name] = self.user_id
|
||||
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
@@ -19,7 +19,7 @@ from openedx.core.djangoapps.schedules.content_highlights import get_week_highli
|
||||
from openedx.core.djangoapps.schedules.exceptions import CourseUpdateDoesNotExist
|
||||
from openedx.core.djangoapps.schedules.models import Schedule, ScheduleExperience
|
||||
from openedx.core.djangoapps.schedules.utils import PrefixedDebugLoggerMixin
|
||||
from openedx.core.djangoapps.schedules.template_context import get_base_template_context
|
||||
from openedx.core.djangoapps.ace_common.template_context import get_base_template_context
|
||||
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration
|
||||
from openedx.features.course_experience import course_home_url_name
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'schedules/edx_ace/common/base_body.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_body.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block preview_text %}
|
||||
@@ -31,9 +31,9 @@
|
||||
</p>
|
||||
|
||||
{% trans "Resume your course now" as course_cta_text %}
|
||||
{% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
|
||||
{% include "ace_common/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
|
||||
|
||||
{% include "schedules/edx_ace/common/upsell_cta.html"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.html"%}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -14,5 +14,5 @@ We want to let you know what you can look forward to in week {{ week_num }}:
|
||||
With self-paced courses, you learn on your own schedule. We encourage you to spend time with the course each week.
|
||||
Your focused attention will pay off in the end!
|
||||
{% endblocktrans %}
|
||||
{% include "schedules/edx_ace/common/upsell_cta.txt"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.txt"%}
|
||||
{% endautoescape %}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% extends 'schedules/edx_ace/common/base_head.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_head.html' %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'schedules/edx_ace/common/base_body.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_body.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block preview_text %}
|
||||
@@ -36,9 +36,9 @@
|
||||
</p>
|
||||
|
||||
{% trans "Keep learning" as course_cta_text %}
|
||||
{% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
|
||||
{% include "ace_common/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
|
||||
|
||||
{% include "schedules/edx_ace/common/upsell_cta.html"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.html"%}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -14,5 +14,5 @@
|
||||
{% endblocktrans %}
|
||||
{% trans "Keep learning" %} <{% with_link_tracking course_url %}>
|
||||
{% endif %}
|
||||
{% include "schedules/edx_ace/common/upsell_cta.txt"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.txt"%}
|
||||
{% endautoescape %}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% extends 'schedules/edx_ace/common/base_head.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_head.html' %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'schedules/edx_ace/common/base_body.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_body.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block preview_text %}
|
||||
@@ -36,9 +36,9 @@
|
||||
</p>
|
||||
|
||||
{% trans "Start learning now" as course_cta_text %}
|
||||
{% include "schedules/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
|
||||
{% include "ace_common/edx_ace/common/return_to_course_cta.html" with course_cta_text=course_cta_text%}
|
||||
|
||||
{% include "schedules/edx_ace/common/upsell_cta.html"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.html"%}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
|
||||
{% trans "Start learning now" %} <{% with_link_tracking course_url %}>
|
||||
{% endif %}
|
||||
{% include "schedules/edx_ace/common/upsell_cta.txt"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.txt"%}
|
||||
{% endautoescape %}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% extends 'schedules/edx_ace/common/base_head.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_head.html' %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends 'schedules/edx_ace/common/base_body.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_body.html' %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% load ace %}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% extends 'schedules/edx_ace/common/base_head.html' %}
|
||||
{% extends 'ace_common/edx_ace/common/base_head.html' %}
|
||||
|
||||
@@ -17,4 +17,4 @@ This is the RED theme!
|
||||
|
||||
{% trans "Start learning now" %} <{% with_link_tracking course_url %}>
|
||||
{% endif %}
|
||||
{% include "schedules/edx_ace/common/upsell_cta.txt"%}
|
||||
{% include "ace_common/edx_ace/common/upsell_cta.txt"%}
|
||||
|
||||
Reference in New Issue
Block a user