From 5ce0319e1261d0c22d571945cc0f60f966afd582 Mon Sep 17 00:00:00 2001 From: "kshitij.sobti" Date: Fri, 22 Nov 2024 11:56:42 +0530 Subject: [PATCH] fixup!: fix quality issues and imports --- openedx/core/djangoapps/agreements/api.py | 7 ++----- openedx/core/djangoapps/agreements/data.py | 4 ++-- .../core/djangoapps/agreements/serializers.py | 3 ++- .../djangoapps/agreements/tests/test_api.py | 21 +++++++++---------- .../djangoapps/agreements/tests/test_views.py | 15 ++++++------- openedx/core/djangoapps/agreements/urls.py | 2 +- openedx/core/djangoapps/agreements/views.py | 19 +++++++++-------- 7 files changed, 35 insertions(+), 36 deletions(-) diff --git a/openedx/core/djangoapps/agreements/api.py b/openedx/core/djangoapps/agreements/api.py index 1c858c7cd598..08f717bca8e8 100644 --- a/openedx/core/djangoapps/agreements/api.py +++ b/openedx/core/djangoapps/agreements/api.py @@ -10,11 +10,8 @@ from django.core.exceptions import ObjectDoesNotExist from opaque_keys.edx.keys import CourseKey -from openedx.core.djangoapps.agreements.models import IntegritySignature, UserAgreementRecord -from openedx.core.djangoapps.agreements.models import LTIPIISignature -from openedx.core.djangoapps.agreements.models import LTIPIITool -from .data import LTIPIISignatureData -from .data import LTIToolsReceivingPIIData, UserAgreementRecordData +from .data import LTIPIISignatureData, LTIToolsReceivingPIIData, UserAgreementRecordData +from .models import IntegritySignature, LTIPIISignature, LTIPIITool, UserAgreementRecord log = logging.getLogger(__name__) User = get_user_model() diff --git a/openedx/core/djangoapps/agreements/data.py b/openedx/core/djangoapps/agreements/data.py index 8f8d69dd20d0..01d83665c009 100644 --- a/openedx/core/djangoapps/agreements/data.py +++ b/openedx/core/djangoapps/agreements/data.py @@ -1,12 +1,12 @@ """ Public data structures for this app. """ +from dataclasses import dataclass from datetime import datetime import attr -from dataclasses import dataclass -from openedx.core.djangoapps.agreements.models import UserAgreementRecord +from .models import UserAgreementRecord @attr.s(frozen=True, auto_attribs=True) diff --git a/openedx/core/djangoapps/agreements/serializers.py b/openedx/core/djangoapps/agreements/serializers.py index 3c6e9f78c201..b0e5dff49163 100644 --- a/openedx/core/djangoapps/agreements/serializers.py +++ b/openedx/core/djangoapps/agreements/serializers.py @@ -3,9 +3,10 @@ """ from rest_framework import serializers -from openedx.core.djangoapps.agreements.models import IntegritySignature, LTIPIISignature from openedx.core.lib.api.serializers import CourseKeyField +from .models import IntegritySignature, LTIPIISignature + class IntegritySignatureSerializer(serializers.ModelSerializer): """ diff --git a/openedx/core/djangoapps/agreements/tests/test_api.py b/openedx/core/djangoapps/agreements/tests/test_api.py index 82bc12cf9f58..dc1b97d62181 100644 --- a/openedx/core/djangoapps/agreements/tests/test_api.py +++ b/openedx/core/djangoapps/agreements/tests/test_api.py @@ -9,23 +9,22 @@ from testfixtures import LogCapture from common.djangoapps.student.tests.factories import UserFactory -from openedx.core.djangoapps.agreements.api import ( +from openedx.core.djangolib.testing.utils import skip_unless_lms +from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase +from xmodule.modulestore.tests.factories import CourseFactory + +from ..api import ( create_integrity_signature, + create_lti_pii_signature, + create_user_agreement_record, get_integrity_signature, get_integrity_signatures_for_course, - get_pii_receiving_lti_tools, - create_lti_pii_signature, get_lti_pii_signature, - create_user_agreement_record, - get_user_agreements, + get_pii_receiving_lti_tools, get_user_agreement_record, + get_user_agreements ) -from openedx.core.djangolib.testing.utils import skip_unless_lms -from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory -from ..models import ( - LTIPIITool, -) +from ..models import LTIPIITool LOGGER_NAME = "openedx.core.djangoapps.agreements.api" diff --git a/openedx/core/djangoapps/agreements/tests/test_views.py b/openedx/core/djangoapps/agreements/tests/test_views.py index c2cf30a6cae5..c369a5ed2128 100644 --- a/openedx/core/djangoapps/agreements/tests/test_views.py +++ b/openedx/core/djangoapps/agreements/tests/test_views.py @@ -13,16 +13,17 @@ from rest_framework.test import APITestCase from common.djangoapps.student.roles import CourseStaffRole -from common.djangoapps.student.tests.factories import UserFactory, AdminFactory -from openedx.core.djangoapps.agreements.api import ( +from common.djangoapps.student.tests.factories import AdminFactory, UserFactory +from openedx.core.djangolib.testing.utils import skip_unless_lms +from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase +from xmodule.modulestore.tests.factories import CourseFactory + +from ..api import ( create_integrity_signature, + create_user_agreement_record, get_integrity_signatures_for_course, - get_lti_pii_signature, create_user_agreement_record + get_lti_pii_signature ) -from openedx.core.djangolib.testing.utils import skip_unless_lms -from xmodule.modulestore.tests.django_utils import \ - ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order @skip_unless_lms diff --git a/openedx/core/djangoapps/agreements/urls.py b/openedx/core/djangoapps/agreements/urls.py index 202a6f11d6b2..902f477a7087 100644 --- a/openedx/core/djangoapps/agreements/urls.py +++ b/openedx/core/djangoapps/agreements/urls.py @@ -3,7 +3,7 @@ """ from django.conf import settings -from django.urls import re_path, path +from django.urls import path, re_path from .views import IntegritySignatureView, LTIPIISignatureView, UserAgreementsView diff --git a/openedx/core/djangoapps/agreements/views.py b/openedx/core/djangoapps/agreements/views.py index d39452e418cc..4a6139f70838 100644 --- a/openedx/core/djangoapps/agreements/views.py +++ b/openedx/core/djangoapps/agreements/views.py @@ -3,25 +3,26 @@ """ import edx_api_doc_tools as apidocs -from django.conf import settings from django import forms +from django.conf import settings from drf_yasg import openapi +from opaque_keys.edx.keys import CourseKey from rest_framework import status -from rest_framework.views import APIView -from rest_framework.response import Response from rest_framework.permissions import IsAuthenticated -from opaque_keys.edx.keys import CourseKey - +from rest_framework.response import Response +from rest_framework.views import APIView from common.djangoapps.student import auth from common.djangoapps.student.roles import CourseStaffRole -from openedx.core.djangoapps.agreements.api import ( + +from .api import ( create_integrity_signature, create_lti_pii_signature, - get_integrity_signature, get_user_agreement_record, create_user_agreement_record, + create_user_agreement_record, + get_integrity_signature, + get_user_agreement_record ) -from openedx.core.djangoapps.agreements.serializers import IntegritySignatureSerializer, LTIPIISignatureSerializer, \ - UserAgreementsSerializer +from .serializers import IntegritySignatureSerializer, LTIPIISignatureSerializer, UserAgreementsSerializer def is_user_course_or_global_staff(user, course_id):