diff --git a/credentials/apps/badges/admin.py b/credentials/apps/badges/admin.py index 1681d13779..11ef64c396 100644 --- a/credentials/apps/badges/admin.py +++ b/credentials/apps/badges/admin.py @@ -6,10 +6,10 @@ from django.contrib.sites.shortcuts import get_current_site from django.core.management import call_command from django.http import HttpResponseRedirect +from django.urls import reverse from django.utils.html import format_html from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ -from django.urls import reverse from credentials.apps.badges.admin_forms import ( BadgePenaltyForm, @@ -21,7 +21,6 @@ PenaltyDataRuleForm, PenaltyDataRuleFormSet, ) - from credentials.apps.badges.models import ( BadgePenalty, BadgeProgress, diff --git a/credentials/apps/badges/admin_forms.py b/credentials/apps/badges/admin_forms.py index f0b2ad227b..64439d1c98 100644 --- a/credentials/apps/badges/admin_forms.py +++ b/credentials/apps/badges/admin_forms.py @@ -9,8 +9,15 @@ from credentials.apps.badges.credly.api_client import CredlyAPIClient from credentials.apps.badges.credly.exceptions import CredlyAPIError -from credentials.apps.badges.models import AbstractDataRule, BadgePenalty, BadgeRequirement, CredlyOrganization, DataRule, PenaltyDataRule -from credentials.apps.badges.utils import get_event_type_keypaths, get_event_type_attr_type_by_keypath +from credentials.apps.badges.models import ( + AbstractDataRule, + BadgePenalty, + BadgeRequirement, + CredlyOrganization, + DataRule, + PenaltyDataRule, +) +from credentials.apps.badges.utils import get_event_type_attr_type_by_keypath, get_event_type_keypaths class CredlyOrganizationAdminForm(forms.ModelForm): diff --git a/credentials/apps/badges/credly/webhooks.py b/credentials/apps/badges/credly/webhooks.py index 1f7307a68b..1b9a115e37 100644 --- a/credentials/apps/badges/credly/webhooks.py +++ b/credentials/apps/badges/credly/webhooks.py @@ -1,13 +1,13 @@ import logging +from django.contrib.sites.shortcuts import get_current_site from django.shortcuts import get_object_or_404 from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView -from django.contrib.sites.shortcuts import get_current_site -from .api_client import CredlyAPIClient from ..models import CredlyBadgeTemplate, CredlyOrganization +from .api_client import CredlyAPIClient logger = logging.getLogger(__name__) diff --git a/credentials/apps/badges/models.py b/credentials/apps/badges/models.py index 0425e894d3..9cbb048b1c 100644 --- a/credentials/apps/badges/models.py +++ b/credentials/apps/badges/models.py @@ -12,12 +12,7 @@ from django_extensions.db.models import TimeStampedModel from model_utils import Choices from model_utils.fields import StatusField -from openedx_events.learning.data import ( - BadgeData, - BadgeTemplateData, - UserData, - UserPersonalData, -) +from openedx_events.learning.data import BadgeData, BadgeTemplateData, UserData, UserPersonalData from credentials.apps.badges.credly.utils import get_credly_base_url from credentials.apps.badges.signals.signals import ( diff --git a/credentials/apps/badges/processing/progression.py b/credentials/apps/badges/processing/progression.py index 9cd3e89120..85e1fcac65 100644 --- a/credentials/apps/badges/processing/progression.py +++ b/credentials/apps/badges/processing/progression.py @@ -3,9 +3,10 @@ """ import logging -from attrs import asdict from typing import List +from attrs import asdict + from credentials.apps.badges.models import BadgeRequirement diff --git a/credentials/apps/badges/processing/regression.py b/credentials/apps/badges/processing/regression.py index 121fba0287..e88e518429 100644 --- a/credentials/apps/badges/processing/regression.py +++ b/credentials/apps/badges/processing/regression.py @@ -3,9 +3,10 @@ """ import logging -from attrs import asdict from typing import List +from attrs import asdict + from credentials.apps.badges.models import BadgePenalty diff --git a/credentials/apps/badges/signals/signals.py b/credentials/apps/badges/signals/signals.py index 6bb1cfe627..c7faf9eaef 100644 --- a/credentials/apps/badges/signals/signals.py +++ b/credentials/apps/badges/signals/signals.py @@ -3,6 +3,7 @@ """ import logging + from django.dispatch import Signal from openedx_events.learning.signals import BADGE_AWARDED, BADGE_REVOKED diff --git a/credentials/apps/badges/tests/test_issuers.py b/credentials/apps/badges/tests/test_issuers.py index 4ec825a493..07a7dae208 100644 --- a/credentials/apps/badges/tests/test_issuers.py +++ b/credentials/apps/badges/tests/test_issuers.py @@ -6,8 +6,8 @@ from credentials.apps.credentials.constants import UserCredentialStatus -from ..models import CredlyBadge, CredlyBadgeTemplate, CredlyOrganization from ..issuers import CredlyBadgeTemplateIssuer +from ..models import CredlyBadge, CredlyBadgeTemplate, CredlyOrganization class CredlyBadgeTemplateIssuer(TestCase): diff --git a/credentials/apps/badges/tests/test_models.py b/credentials/apps/badges/tests/test_models.py index d8473d25c4..05ad6c370f 100644 --- a/credentials/apps/badges/tests/test_models.py +++ b/credentials/apps/badges/tests/test_models.py @@ -3,7 +3,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.test import TestCase -from openedx_events.learning.data import BadgeData, UserData, UserPersonalData, BadgeTemplateData +from openedx_events.learning.data import BadgeData, BadgeTemplateData, UserData, UserPersonalData from credentials.apps.badges.models import ( BadgeProgress, diff --git a/credentials/apps/badges/tests/test_signals.py b/credentials/apps/badges/tests/test_signals.py index c2562dc407..3bc040089a 100644 --- a/credentials/apps/badges/tests/test_signals.py +++ b/credentials/apps/badges/tests/test_signals.py @@ -4,12 +4,8 @@ from django.contrib.contenttypes.models import ContentType from django.test import TestCase -from credentials.apps.badges.models import ( - CredlyBadge, - CredlyBadgeTemplate, - CredlyOrganization, -) from credentials.apps.badges.issuers import CredlyBadgeTemplateIssuer +from credentials.apps.badges.models import CredlyBadge, CredlyBadgeTemplate, CredlyOrganization from credentials.apps.badges.signals.signals import BADGE_PROGRESS_COMPLETE, BADGE_PROGRESS_INCOMPLETE diff --git a/credentials/apps/badges/tests/test_utils.py b/credentials/apps/badges/tests/test_utils.py index 16fe4dde67..b6e352e2d7 100644 --- a/credentials/apps/badges/tests/test_utils.py +++ b/credentials/apps/badges/tests/test_utils.py @@ -1,24 +1,24 @@ import unittest - -from attr import asdict from datetime import datetime -from django.conf import settings from unittest.mock import patch +from attr import asdict from django.conf import settings -from openedx_events.learning.data import UserData, UserPersonalData, CourseData, CoursePassingStatusData from opaque_keys.edx.keys import CourseKey +from openedx_events.learning.data import CourseData, CoursePassingStatusData, UserData, UserPersonalData from credentials.apps.badges.checks import badges_checks -from credentials.apps.badges.credly.utils import get_credly_base_url, get_credly_api_base_url -from credentials.apps.badges.utils import ( +from credentials.apps.badges.credly.utils import get_credly_api_base_url, get_credly_base_url +from credentials.apps.badges.utils import ( credly_check, extract_payload, - get_event_type_keypaths, - get_user_data, keypath, get_event_type_attr_type_by_keypath, + get_event_type_keypaths, + get_user_data, + keypath, ) + COURSE_PASSING_EVENT = "org.openedx.learning.course.passing.status.updated.v1" class TestKeypath(unittest.TestCase): diff --git a/credentials/apps/badges/toggles.py b/credentials/apps/badges/toggles.py index bbc709e491..bd54217ded 100644 --- a/credentials/apps/badges/toggles.py +++ b/credentials/apps/badges/toggles.py @@ -4,6 +4,7 @@ from edx_toggles.toggles import SettingToggle + # .. toggle_name: BADGES_ENABLED # .. toggle_implementation: DjangoSetting # .. toggle_default: False diff --git a/credentials/apps/badges/utils.py b/credentials/apps/badges/utils.py index 4a1fb1dc23..d327fe579d 100644 --- a/credentials/apps/badges/utils.py +++ b/credentials/apps/badges/utils.py @@ -1,6 +1,6 @@ -import attr import inspect +import attr from attrs import asdict from django.conf import settings from openedx_events.learning.data import UserData diff --git a/credentials/tests/test_utils.py b/credentials/tests/test_utils.py index b65441adfd..7d803cd7ee 100644 --- a/credentials/tests/test_utils.py +++ b/credentials/tests/test_utils.py @@ -1,7 +1,6 @@ import platform import sys import unittest - from logging.handlers import SysLogHandler from os import path from unittest.mock import patch