Fix quality issues in ace_common
This commit is contained in:
@@ -1 +1,5 @@
|
||||
default_app_config = 'openedx.core.djangoapps.ace_common.apps.AceCommonConfig'
|
||||
"""
|
||||
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
|
||||
|
||||
@@ -1,7 +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,3 +1,4 @@
|
||||
# pylint: disable=missing-docstring
|
||||
from urlparse import urlparse
|
||||
|
||||
from crum import get_current_request
|
||||
@@ -7,7 +8,7 @@ from django.utils.safestring import mark_safe
|
||||
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
|
||||
@@ -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')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# pylint: disable=missing-docstring,no-member
|
||||
from unittest import TestCase
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user