INCR-112: python-modernize openedx/core/djangoapps/ace_common (#20409)
* INCR-112: python-modernize openedx/core/djangoapps/ace_common * isort * suppress pylint errors * Fix pylint disable
This commit is contained in:
committed by
Michael Youngstrom
parent
02f7b75720
commit
d9cd033e49
@@ -1,10 +1,12 @@
|
||||
"""
|
||||
Configuration for the ace_common Django app.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from openedx.core.djangoapps.plugins.constants import ProjectType, PluginSettings, SettingsType
|
||||
from openedx.core.djangoapps.plugins.constants import PluginSettings, ProjectType, SettingsType
|
||||
|
||||
|
||||
class AceCommonConfig(AppConfig):
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""
|
||||
Base Message types to be used to construct ace messages.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from edx_ace.message import MessageType
|
||||
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Settings for edX ACE on devstack.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from openedx.core.djangoapps.ace_common.settings import common
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""
|
||||
Context dictionary for templates that use the ace_common base template.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import NoReverseMatch
|
||||
from django.urls import reverse
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import urlparse
|
||||
from __future__ import absolute_import
|
||||
|
||||
from crum import get_current_request
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
from six.moves.urllib.parse import urlparse # pylint: disable=import-error
|
||||
|
||||
from openedx.core.djangoapps.ace_common.tracking import CampaignTrackingInfo, GoogleAnalyticsTrackingPixel
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import parse_qs, urlparse
|
||||
import uuid
|
||||
from django.http import HttpRequest
|
||||
from mock import patch
|
||||
from __future__ import absolute_import
|
||||
|
||||
import uuid
|
||||
|
||||
from django.http import HttpRequest
|
||||
from edx_ace import Message, Recipient
|
||||
from mock import patch
|
||||
from six.moves.urllib.parse import parse_qs, urlparse # pylint: disable=import-error
|
||||
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
|
||||
from student.tests.factories import UserFactory
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
"""
|
||||
Tests for ace message module
|
||||
"""
|
||||
import ddt
|
||||
from mock import patch
|
||||
from __future__ import absolute_import
|
||||
|
||||
import ddt
|
||||
from django.test import TestCase
|
||||
from mock import patch
|
||||
|
||||
from openedx.core.djangoapps.ace_common.message import BaseMessageType
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.template import VariableDoesNotExist
|
||||
from django.test import override_settings
|
||||
|
||||
from openedx.core.djangoapps.ace_common.templatetags.ace import (
|
||||
_get_google_analytics_tracking_url,
|
||||
ensure_url_is_absolute,
|
||||
with_link_tracking,
|
||||
google_analytics_tracking_pixel,
|
||||
_get_google_analytics_tracking_url
|
||||
with_link_tracking
|
||||
)
|
||||
from openedx.core.djangoapps.ace_common.tests.mixins import EmailTemplateTagMixin, QueryStringAssertionMixin
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteFactory
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from __future__ import absolute_import
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
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,
|
||||
GoogleAnalyticsTrackingPixel)
|
||||
DEFAULT_CAMPAIGN_SOURCE,
|
||||
CampaignTrackingInfo,
|
||||
GoogleAnalyticsTrackingPixel
|
||||
)
|
||||
from openedx.core.djangoapps.site_configuration.tests.factories import SiteConfigurationFactory
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import parse_qs
|
||||
from __future__ import absolute_import
|
||||
|
||||
import attr
|
||||
import six
|
||||
from django.utils.http import urlencode
|
||||
from six.moves.urllib.parse import parse_qs # pylint: disable=import-error, ungrouped-imports
|
||||
|
||||
from openedx.core.djangoapps.theming.helpers import get_config_value_from_site_or_settings
|
||||
|
||||
@@ -38,7 +40,7 @@ class CampaignTrackingInfo(object):
|
||||
if existing_query_string is not None:
|
||||
parameters = parse_qs(existing_query_string)
|
||||
|
||||
for attribute, value in attr.asdict(self).iteritems():
|
||||
for attribute, value in six.iteritems(attr.asdict(self)):
|
||||
if value is not None:
|
||||
parameters['utm_' + attribute] = [value]
|
||||
return urlencode(parameters, doseq=True)
|
||||
@@ -104,7 +106,7 @@ class GoogleAnalyticsTrackingPixel(object):
|
||||
|
||||
if self.course_id is not None and self.event_label is None:
|
||||
param_name = fields.event_label.metadata['param_name']
|
||||
parameters[param_name] = unicode(self.course_id)
|
||||
parameters[param_name] = six.text_type(self.course_id)
|
||||
|
||||
return u"https://www.google-analytics.com/collect?{params}".format(params=urlencode(parameters))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user