diff --git a/openedx/core/djangoapps/content_tagging/api.py b/openedx/core/djangoapps/content_tagging/api.py index 693a769b9e86..4ff21dff3f3b 100644 --- a/openedx/core/djangoapps/content_tagging/api.py +++ b/openedx/core/djangoapps/content_tagging/api.py @@ -3,7 +3,7 @@ """ from __future__ import annotations -from typing import Iterator, List, Type +from typing import Iterator import openedx_tagging.core.tagging.api as oel_tagging from django.db.models import Q, QuerySet, Exists, OuterRef @@ -38,7 +38,7 @@ def create_taxonomy( def set_taxonomy_orgs( taxonomy: Taxonomy, all_orgs=False, - orgs: List[Organization] = None, + orgs: list[Organization] = None, relationship: TaxonomyOrg.RelType = TaxonomyOrg.RelType.OWNER, ): """ diff --git a/openedx/core/djangoapps/content_tagging/migrations/0006_simplify_models.py b/openedx/core/djangoapps/content_tagging/migrations/0006_simplify_models.py new file mode 100644 index 000000000000..7e8eb99ee71c --- /dev/null +++ b/openedx/core/djangoapps/content_tagging/migrations/0006_simplify_models.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.21 on 2023-09-29 23:32 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('content_tagging', '0005_auto_20230830_1517'), + ] + + operations = [ + migrations.DeleteModel( + name='ContentAuthorTaxonomy', + ), + migrations.DeleteModel( + name='ContentLanguageTaxonomy', + ), + migrations.DeleteModel( + name='ContentTaxonomy', + ), + ] diff --git a/openedx/core/djangoapps/content_tagging/models/base.py b/openedx/core/djangoapps/content_tagging/models/base.py index ff7b6d1402a6..77061e46118a 100644 --- a/openedx/core/djangoapps/content_tagging/models/base.py +++ b/openedx/core/djangoapps/content_tagging/models/base.py @@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError from django.db import models -from django.db.models import Exists, OuterRef, Q, QuerySet +from django.db.models import Q, QuerySet from django.utils.translation import gettext as _ from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import LearningContextKey, UsageKey @@ -108,5 +108,5 @@ def clean(self): # Make sure that object_id is a valid key try: self.object_key - except InvalidKeyError: - raise ValidationError("object_id is not a valid opaque key string.") + except InvalidKeyError as err: + raise ValidationError("object_id is not a valid opaque key string.") from err diff --git a/openedx/core/djangoapps/content_tagging/tasks.py b/openedx/core/djangoapps/content_tagging/tasks.py index 33b88cc3fda5..f28b6d156dcc 100644 --- a/openedx/core/djangoapps/content_tagging/tasks.py +++ b/openedx/core/djangoapps/content_tagging/tasks.py @@ -76,7 +76,6 @@ def update_course_tags(course_key_str: str) -> bool: return True except Exception as e: # pylint: disable=broad-except log.error("Error updating tags for Course with id: %s. %s", course_key, e) - raise e return False diff --git a/openedx/core/djangoapps/content_tagging/tests/test_api.py b/openedx/core/djangoapps/content_tagging/tests/test_api.py index 3b0a20fafdef..c0595dffb679 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_api.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_api.py @@ -2,7 +2,7 @@ import ddt from django.test.testcases import TestCase from opaque_keys.edx.keys import CourseKey, UsageKey -from openedx_tagging.core.tagging.models import ObjectTag, Tag +from openedx_tagging.core.tagging.models import Tag from organizations.models import Organization from .. import api diff --git a/openedx/core/djangoapps/content_tagging/tests/test_rules.py b/openedx/core/djangoapps/content_tagging/tests/test_rules.py index a096e04f36f6..013b82255840 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_rules.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_rules.py @@ -3,7 +3,6 @@ import ddt from django.contrib.auth import get_user_model from django.test.testcases import TestCase, override_settings -from opaque_keys import InvalidKeyError from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from openedx_tagging.core.tagging.models import ( Tag, diff --git a/openedx/core/djangoapps/content_tagging/tests/test_tasks.py b/openedx/core/djangoapps/content_tagging/tests/test_tasks.py index aba87d25f734..f3c964b836c7 100644 --- a/openedx/core/djangoapps/content_tagging/tests/test_tasks.py +++ b/openedx/core/djangoapps/content_tagging/tests/test_tasks.py @@ -8,7 +8,7 @@ from django.core.management import call_command from django.test import override_settings from edx_toggles.toggles.testutils import override_waffle_flag -from openedx_tagging.core.tagging.models import LanguageTaxonomy, ObjectTag, Tag, Taxonomy +from openedx_tagging.core.tagging.models import LanguageTaxonomy, Tag, Taxonomy from organizations.models import Organization from common.djangoapps.student.tests.factories import UserFactory