Documents Tagging architecture decisions - #55
Conversation
to openedx_tagging.core.tagging as per ADR 0007.
|
Thanks for the pull request, @pomegranited! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
f7837f5 to
2182b55
Compare
|
@pomegranited Great work! 👍 I think we need also to specify how will the link with the contents be handled. I have seen that ContenTag is mentioned in the ADRs, but I feel that it has to be specified more. Specify that we have to create subclasses of ObjectTag to link the content, like ContentTag or the class to link the learning core content. |
|
|
||
| Permission #1 requires no external access, so can be enforced by the ``openedx_tagging`` app. | ||
|
|
||
| But because permissions #2 + #3 require access to the edx-platform CMS model `CourseCreator`_, this access can only be enforced in Studio, and so will live under `cms.djangoapps.tagging` along with the ``ContentTag`` class. Tagging MVP must work for libraries v1, v2 and courses created in Studio, and so tying these permissions to Studio is reasonable for the MVP. |
There was a problem hiding this comment.
Per OEP-9, these three rules that you listed above can be defined using rules... with #1 defined in openedx_tagging and #2 and #3 defined in Studio. I think that what that gets us is that any application can then use the standard Django API to query things like user.has_perm('openedx_tagging.edit_taxonomy', taxonomy) and get the right result without needing to be aware of how those permissions are defined or even where they are defined (in Studio).
There was a problem hiding this comment.
That would be really cool @bradenmacdonald , but can django-rules handle chaining multiple rule definitions together?
Ref rules.RuleSet:
add_ruleraises a KeyError if another rule by that name already exists.set_rulesets the rule, regardless of whether one already exists
But I don't see how to combine them?
There was a problem hiding this comment.
@pomegranited Isn't combining rules what you mean? It supports combining rules with "and", "or", "not", etc.
There was a problem hiding this comment.
@bradenmacdonald Yes, we can combine rules logically and explicitly -- what I meant was, there's no magic provided by django or django-rules to chain these calls to set_rule.
It's totally doable, it just takes a little care. For example:
openedx_taggingcallsset_rule('openedx_tagging.edit_taxonomy', can_edit_taxonomy)wherecan_edit_taxonomychecks e.guser.is_staff | user.is_superuser. This is fine,openedx_taggingcan stand alone.openedx.features.tagging.SystemTaxonomymight want to callset_rule('openedx_tagging.edit_taxonomy', can_edit_taxonomy)too, where itscan_edit_taxonomydisallows editing for all SystemTaxonomy no matter who you are.openedx.features.tagging.OrgTaxonomymight want to callset_rule('openedx_tagging.edit_taxonomy', can_edit_taxonomy)too, where itscan_edit_taxonomychecksopenedx_tagging.can_edit_taxonomyand the user's rights against the OrgTaxonomy.org.
But they can't all pile on and call set_rule, because the most recently called set_rule wins.
So to make sure user.has_perm('openedx_tagging.edit_taxonomy', taxonomy) returns the right thing, the openedx.features.tagging rules must be aware of its different Taxonomy subclasses, and explicitly combine with the openedx_tagging rules where needed.
There was a problem hiding this comment.
@pomegranited Ah, I see. Yeah it's too bad there's not a nice API for combining those. maybe we can add a lightweight way to do that?
There was a problem hiding this comment.
@bradenmacdonald Sure, will see.. I'll start by trying to use consistent convention, and if it ends up being abstractable into something we can reuse, that would be awesome :) Thanks for pointing me to OEP-9 here, and clarifying the end goal of these permission rules.
| Instance | ||
| ~~~~~~~~ | ||
|
|
||
| A Taxonomy can be enabled/disabled for all contexts using its ``enabled`` flag. |
There was a problem hiding this comment.
I think this needs to be clarified. It sounds like this is saying "the taxonomy can be enabled for all contexts (forced on for all courses, regardless of other settings) when enabled=True or disabled for all contexts (forced off for all courses, regardless of other settings) when enabled=False". We either need a third state (can be selectively enabled/disabled at other levels when this is set to None), or make this into either a "global disable" or "global enable" boolean, but not both. I hope that makes sense.
There was a problem hiding this comment.
Yep, that makes sense @bradenmacdonald . Does this look clearer? https://github.com/open-craft/openedx-learning/blob/jill/tagging-data-arch-adr/docs/decisions/0010-taxonomy-enable-context.rst
| """ | ||
|
|
||
| # Content id to which this tag is associated | ||
| content_id = models.CharField(max_length=255) |
There was a problem hiding this comment.
I think some namespacing spec is required here.
What if I want to tag a user, which has a numeric ID? Should we specify the format for this field? Perhaps that it's always an "Opaque Key" serialized as a string, or that if it's not an opaque key, it's a similarly prefixed string like "user:15" ?
There was a problem hiding this comment.
Note that this model is going to change substantially when we start implementation -- I just included it here because #54 adds it, and I needed to move it under openedx_tagging.
But re your comment: I'd rather add a short string content_type field than prefix the content_id -- or in terms of the ObjectTag class that will ultimately be the base class for ContentTag, I'd rather use object_type and object_id fields.
There was a problem hiding this comment.
Yep, that sounds good! As long as it's namespaced in some way.
184962d to
9f38046
Compare
also fixes up some link typos in ADR 10
|
Thank you for your feedback @ChrisChV @bradenmacdonald -- I've addressed what I can from your comments, and from watching the meeting on 6 June. @ormsbee did you have any comments or changes needed here? I guess I'm also not sure how much of the data model document needs to be enshrined in ADRs, and how much can be done when we do the implementation.. Is there anything missing that should be in here? |
| +-------------+-----------------------------+--------------------------+-------------------------------+ | ||
| | True | False | True | False | | ||
| +-------------+-----------------------------+--------------------------+-------------------------------+ | ||
| | True | True | False | False | |
There was a problem hiding this comment.
If the course hasn't enabled all taxonomies, but it has enabled this specific one, shouldn't it be shown for the course?
There was a problem hiding this comment.
I think this doesn't allow enabling taxonomies at the course level (yet)... I misunderstood this at first too, but I think tax.enabled_for(course.org) means tax.enabled_for(org) (where org comes from the course), not tax.enabled_for(course | org) as I first read this.
|
Thanks. I like how this is shaping up! |
|
@bradenmacdonald @ormsbee Thanks for your comments! I'm pretty pleased with it too :) If you're happy with what's here, could one of you approve and squash+merge? |
|
Thanks for your 👍 @bradenmacdonald :) I don't have merge rights here, so could you or @ormsbee merge if it's ready? Thank you! |
|
@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
This PR documents the decisions that arose from openedx/modular-learning#60.
It also builds on #54 and enforces ADR 7. Tagging app structure by moving the tagging app to a separate package outside of
openedx_learning, calledopenedx_tagging. The models in this app will be altered and aligned with the other ADRs as part of subsequent PRs.Testing instructions
openedx_taggingtest runs.Supporting information
Closes openedx/modular-learning#60