-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom Taxonomy, ObjectTag subclasses to customize tagging beha…
…vior (#62) Adds support for custom Taxonomy subclasses to be stored against a Taxonomy, to be used by the python API when instantiating and returning Taxonomies. Also adds minimal support for ObjectTag subclasses. However, these are not stored against the ObjectTag instances; they can be instantiated by the Taxonomy subclasses if and when needed. Related: * docs: updates decisions to reflect this change * feat: adds api.get_taxonomy, which returns a Taxonomy cast to its subclass, when set * refactor: adds _check_taxonomy, _check_tag, and _check_object methods to the Taxonomy class, which can be overridden by subclasses when validating ObjectTags Added to support system-defined Taxonomies: * feat: adds un-editable Taxonomy.system_defined field so that system taxonomies can store this field and ensure no one edits them. * feat: adds Taxonomy.visible_to_authors, which is needed for fully automated tagging. Cleanup changes: * fix: updates Tag model to cascade delete if the Taxonomy or parent Tag is deleted. * style: adds missing type annotations to rules and python API
- Loading branch information
1 parent
a5b109f
commit f5164bb
Showing
11 changed files
with
695 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
openedx_tagging/core/tagging/migrations/0002_auto_20230718_2026.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Generated by Django 3.2.19 on 2023-07-18 05:54 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
import openedx_learning.lib.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("oel_tagging", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="taxonomy", | ||
name="system_defined", | ||
field=models.BooleanField( | ||
default=False, | ||
editable=False, | ||
help_text="Indicates that tags and metadata for this taxonomy are maintained by the system; taxonomy admins will not be permitted to modify them.", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="tag", | ||
name="parent", | ||
field=models.ForeignKey( | ||
default=None, | ||
help_text="Tag that lives one level up from the current tag, forming a hierarchy.", | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="children", | ||
to="oel_tagging.tag", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="tag", | ||
name="taxonomy", | ||
field=models.ForeignKey( | ||
default=None, | ||
help_text="Namespace and rules for using a given set of tags.", | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="oel_tagging.taxonomy", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="taxonomy", | ||
name="visible_to_authors", | ||
field=models.BooleanField( | ||
default=True, | ||
editable=False, | ||
help_text="Indicates whether this taxonomy should be visible to object authors.", | ||
), | ||
), | ||
migrations.RemoveField( | ||
model_name="objecttag", | ||
name="object_type", | ||
), | ||
migrations.AddField( | ||
model_name="taxonomy", | ||
name="_taxonomy_class", | ||
field=models.CharField( | ||
help_text="Taxonomy subclass used to instantiate this instance; must be a fully-qualified module and class name. If the module/class cannot be imported, an error is logged and the base Taxonomy class is used instead.", | ||
max_length=255, | ||
null=True, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="objecttag", | ||
name="object_id", | ||
field=openedx_learning.lib.fields.MultiCollationCharField( | ||
db_collations={"mysql": "utf8mb4_unicode_ci", "sqlite": "NOCASE"}, | ||
editable=False, | ||
help_text="Identifier for the object being tagged", | ||
max_length=255, | ||
), | ||
), | ||
] |
Oops, something went wrong.