|
2 | 2 | Package where filters related to the learning architectural subdomain are implemented.
|
3 | 3 | """
|
4 | 4 |
|
5 |
| -from typing import Any, Optional |
| 5 | +from typing import Any, Optional, Union |
6 | 6 |
|
7 | 7 | from django.db.models.query import QuerySet
|
8 | 8 | from django.http import HttpResponse, QueryDict
|
@@ -94,7 +94,7 @@ def __init__(self, message: str, response: Optional[HttpResponse] = None) -> Non
|
94 | 94 | super().__init__(message, response=response)
|
95 | 95 |
|
96 | 96 | @classmethod
|
97 |
| - def run_filter(cls, context: dict, template_name: str) -> tuple[dict, str]: |
| 97 | + def run_filter(cls, context: dict[str, Any], template_name: str) -> tuple[dict[str, Any] | None, str | None]: |
98 | 98 | """
|
99 | 99 | Process the input context and template_name using the configured pipeline steps to modify the account settings.
|
100 | 100 |
|
@@ -159,7 +159,7 @@ def run_filter(cls, form_data: QueryDict) -> QueryDict:
|
159 | 159 | """
|
160 | 160 | sensitive_data = cls.extract_sensitive_data(form_data)
|
161 | 161 | data = super().run_pipeline(form_data=form_data)
|
162 |
| - form_data = data.get("form_data") |
| 162 | + form_data = data.get("form_data", QueryDict()) |
163 | 163 | form_data.update(sensitive_data)
|
164 | 164 | return form_data
|
165 | 165 |
|
@@ -249,7 +249,7 @@ class PreventEnrollment(OpenEdxFilterException):
|
249 | 249 | """
|
250 | 250 |
|
251 | 251 | @classmethod
|
252 |
| - def run_filter(cls, user: Any, course_key: CourseKey, mode: str) -> tuple[Any, CourseKey, str]: |
| 252 | + def run_filter(cls, user: Any, course_key: CourseKey, mode: str) -> tuple[Any, CourseKey | None, str | None]: |
253 | 253 | """
|
254 | 254 | Process the user, course_key, and mode using the configured pipeline steps to modify the enrollment process.
|
255 | 255 |
|
@@ -345,14 +345,14 @@ class PreventCertificateCreation(OpenEdxFilterException):
|
345 | 345 |
|
346 | 346 | @classmethod
|
347 | 347 | def run_filter( # pylint: disable=too-many-positional-arguments
|
348 |
| - cls: type, |
| 348 | + cls, |
349 | 349 | user: Any,
|
350 | 350 | course_key: CourseKey,
|
351 | 351 | mode: str,
|
352 | 352 | status: str,
|
353 | 353 | grade: float,
|
354 | 354 | generation_mode: str,
|
355 |
| - ) -> tuple[Any, CourseKey, str, str, float, str]: |
| 355 | + ) -> tuple[Any, CourseKey | None, str | None, str | None, float | None, str | None]: |
356 | 356 | """
|
357 | 357 | Process the inputs using the configured pipeline steps to modify the certificate creation process.
|
358 | 358 |
|
@@ -460,7 +460,7 @@ def __init__(self, message: str, response: HttpResponse) -> None:
|
460 | 460 | )
|
461 | 461 |
|
462 | 462 | @classmethod
|
463 |
| - def run_filter(cls, context: dict, custom_template: Any) -> tuple[dict, Any]: |
| 463 | + def run_filter(cls, context: dict, custom_template: Any) -> tuple[dict[str, Any] | None, Any]: |
464 | 464 | """
|
465 | 465 | Process the context and custom_template using the configured pipeline steps to modify the certificate rendering.
|
466 | 466 |
|
@@ -646,7 +646,7 @@ def __init__(self, message: str, response: HttpResponse) -> None:
|
646 | 646 | )
|
647 | 647 |
|
648 | 648 | @classmethod
|
649 |
| - def run_filter(cls, context: dict, template_name: str) -> tuple[dict, str]: |
| 649 | + def run_filter(cls, context: dict[str, Any], template_name: str) -> tuple[dict[str, Any] | None, str | None]: |
650 | 650 | """
|
651 | 651 | Process the context and template_name using the configured pipeline steps to modify the course about rendering.
|
652 | 652 |
|
@@ -745,7 +745,7 @@ def __init__(self, message: str, response: Optional[HttpResponse] = None) -> Non
|
745 | 745 | )
|
746 | 746 |
|
747 | 747 | @classmethod
|
748 |
| - def run_filter(cls, context: dict, template_name: str) -> tuple[dict, str]: |
| 748 | + def run_filter(cls, context: dict[str, Any], template_name: str) -> tuple[dict[str, Any] | None, str | None]: |
749 | 749 | """
|
750 | 750 | Process the context and template_name using the configured pipeline steps to modify the dashboard rendering.
|
751 | 751 |
|
@@ -790,7 +790,7 @@ class PreventChildBlockRender(OpenEdxFilterException):
|
790 | 790 | """
|
791 | 791 |
|
792 | 792 | @classmethod
|
793 |
| - def run_filter(cls, block: Any, context: dict) -> tuple[Any, dict]: |
| 793 | + def run_filter(cls, block: Any, context: dict[str, Any]) -> tuple[Any, dict[str, Any] | None]: |
794 | 794 | """
|
795 | 795 | Process the block and context using the configured pipeline steps to modify the rendering of a child block.
|
796 | 796 |
|
@@ -833,7 +833,7 @@ class PreventEnrollmentQuerysetRequest(OpenEdxFilterException):
|
833 | 833 | """
|
834 | 834 |
|
835 | 835 | @classmethod
|
836 |
| - def run_filter(cls, enrollments: QuerySet) -> QuerySet: |
| 836 | + def run_filter(cls, enrollments: QuerySet) -> QuerySet | None: |
837 | 837 | """
|
838 | 838 | Process the enrollments QuerySet using the configured pipeline steps to modify the course enrollment data.
|
839 | 839 |
|
@@ -891,7 +891,11 @@ def __init__(self, message: str, response: Optional[HttpResponse] = None):
|
891 | 891 | super().__init__(message, response=response)
|
892 | 892 |
|
893 | 893 | @classmethod
|
894 |
| - def run_filter(cls, context: dict, student_view_context: dict): |
| 894 | + def run_filter( |
| 895 | + cls, |
| 896 | + context: dict[str, Any], |
| 897 | + student_view_context: dict |
| 898 | + ) -> tuple[dict[str, Any] | None, dict[str, Any] | None]: |
895 | 899 | """
|
896 | 900 | Process the inputs using the configured pipeline steps to modify the rendering of an XBlock.
|
897 | 901 |
|
@@ -936,7 +940,13 @@ class PreventVerticalBlockRender(OpenEdxFilterException):
|
936 | 940 | """
|
937 | 941 |
|
938 | 942 | @classmethod
|
939 |
| - def run_filter(cls, block: Any, fragment: Any, context: dict, view: str) -> tuple[Any, Any, dict, str]: |
| 943 | + def run_filter( |
| 944 | + cls, |
| 945 | + block: Any, |
| 946 | + fragment: Any, |
| 947 | + context: dict[str, Any], |
| 948 | + view: str |
| 949 | + ) -> tuple[Any, Any, dict[str, Any] | None, str | None]: |
940 | 950 | """
|
941 | 951 | Process the inputs using the configured pipeline steps to modify the rendering of a vertical block.
|
942 | 952 |
|
@@ -976,7 +986,7 @@ class CourseHomeUrlCreationStarted(OpenEdxPublicFilter):
|
976 | 986 | filter_type = "org.openedx.learning.course.homepage.url.creation.started.v1"
|
977 | 987 |
|
978 | 988 | @classmethod
|
979 |
| - def run_filter(cls, course_key: CourseKey, course_home_url: str) -> tuple[CourseKey, str]: |
| 989 | + def run_filter(cls, course_key: CourseKey, course_home_url: str) -> tuple[CourseKey | None, str | None]: |
980 | 990 | """
|
981 | 991 | Process the course_key and course_home_url using the configured pipeline steps to modify the course home url.
|
982 | 992 |
|
@@ -1013,7 +1023,11 @@ class CourseEnrollmentAPIRenderStarted(OpenEdxPublicFilter):
|
1013 | 1023 | filter_type = "org.openedx.learning.home.enrollment.api.rendered.v1"
|
1014 | 1024 |
|
1015 | 1025 | @classmethod
|
1016 |
| - def run_filter(cls, course_key: CourseKey, serialized_enrollment: dict) -> tuple[CourseKey, dict]: |
| 1026 | + def run_filter( |
| 1027 | + cls, |
| 1028 | + course_key: CourseKey, |
| 1029 | + serialized_enrollment: dict[str, Any] |
| 1030 | + ) -> tuple[CourseKey | None, dict[str, Any] | None]: |
1017 | 1031 | """
|
1018 | 1032 | Process the inputs using the configured pipeline steps to modify the course enrollment data.
|
1019 | 1033 |
|
@@ -1050,7 +1064,7 @@ class CourseRunAPIRenderStarted(OpenEdxPublicFilter):
|
1050 | 1064 | filter_type = "org.openedx.learning.home.courserun.api.rendered.started.v1"
|
1051 | 1065 |
|
1052 | 1066 | @classmethod
|
1053 |
| - def run_filter(cls, serialized_courserun: dict) -> dict: |
| 1067 | + def run_filter(cls, serialized_courserun: dict[str, Any]) -> dict[str, Any] | None: |
1054 | 1068 | """
|
1055 | 1069 | Process the serialized_courserun using the configured pipeline steps to modify the course run data.
|
1056 | 1070 |
|
@@ -1145,7 +1159,7 @@ def __init__(self, message: str, response: Optional[HttpResponse] = None):
|
1145 | 1159 | )
|
1146 | 1160 |
|
1147 | 1161 | @classmethod
|
1148 |
| - def run_filter(cls, context: dict, template_name: str) -> tuple[dict, str]: |
| 1162 | + def run_filter(cls, context: dict[str, Any], template_name: str) -> tuple[dict[str, Any] | None, str | None]: |
1149 | 1163 | """
|
1150 | 1164 | Process the context and template_name using the configured pipeline steps to modify the instructor dashboard.
|
1151 | 1165 |
|
@@ -1203,7 +1217,7 @@ def __init__(
|
1203 | 1217 | super().__init__(message, context=context, template_name=template_name)
|
1204 | 1218 |
|
1205 | 1219 | @classmethod
|
1206 |
| - def run_filter(cls, context: dict, template_name: str) -> tuple[dict, str]: |
| 1220 | + def run_filter(cls, context: dict[str, Any], template_name: str) -> tuple[dict[str, Any] | None, str | None]: |
1207 | 1221 | """
|
1208 | 1222 | Process the context and template_name using the configured pipeline steps to modify the submission view.
|
1209 | 1223 |
|
@@ -1240,7 +1254,7 @@ class IDVPageURLRequested(OpenEdxPublicFilter):
|
1240 | 1254 | filter_type = "org.openedx.learning.idv.page.url.requested.v1"
|
1241 | 1255 |
|
1242 | 1256 | @classmethod
|
1243 |
| - def run_filter(cls, url: str) -> str: |
| 1257 | + def run_filter(cls, url: str) -> str | None: |
1244 | 1258 | """
|
1245 | 1259 | Process the URL using the configured pipeline steps to modify the ID verification page URL.
|
1246 | 1260 |
|
@@ -1274,7 +1288,7 @@ class CourseAboutPageURLRequested(OpenEdxPublicFilter):
|
1274 | 1288 | filter_type = "org.openedx.learning.course_about.page.url.requested.v1"
|
1275 | 1289 |
|
1276 | 1290 | @classmethod
|
1277 |
| - def run_filter(cls, url: str, org: str) -> tuple[str, str]: |
| 1291 | + def run_filter(cls, url: str, org: str) -> tuple[str | None, str | None]: |
1278 | 1292 | """
|
1279 | 1293 | Process the URL and org using the configured pipeline steps to modify the course about page URL.
|
1280 | 1294 |
|
@@ -1312,7 +1326,7 @@ class ScheduleQuerySetRequested(OpenEdxPublicFilter):
|
1312 | 1326 | filter_type = "org.openedx.learning.schedule.queryset.requested.v1"
|
1313 | 1327 |
|
1314 | 1328 | @classmethod
|
1315 |
| - def run_filter(cls, schedules: QuerySet) -> QuerySet: |
| 1329 | + def run_filter(cls, schedules: QuerySet) -> QuerySet | None: |
1316 | 1330 | """
|
1317 | 1331 | Process the schedules QuerySet using the configured pipeline steps to modify the schedules data.
|
1318 | 1332 |
|
|
0 commit comments