Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds Content Tagging #32661

Conversation

pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Jul 6, 2023

Description

Adds the models, APIs, and permissions/rules for openedx.features.content_tagging, which builds on the oel_tagging app changes made by openedx/openedx-learning#62

These changes are the first step towards allow Course Authors to tag content objects (courses, units, libraries) in edx-platform, but none of these changes are user-facing yet.

Supporting information

Part of openedx/modular-learning#63

Testing instructions

This change should be 100% covered by unit tests.

But since there's no public-facing APIs yet, if you want to do any further verification, you can test the functionality from the devstack and shell.

  1. Get the master openedx/devstack up and running.
  2. Pull this branch into edx-platform
  3. Install dependencies and update migrations by running paver install_prereqs in the LMS shell (from devstack dir, run make lms-shell) and CMS shell (make studio-shell).
  4. Run the migrations added here by running ./manage.py lms migrate in the LMS shell.
  5. Create file cms/envs/private.py which contains the following. You may need to restart Studio for these changes to take effect: make dev.restart-devserver.studio
    from .devstack import FEATURES
    # Org-based course authoring restrictions
    FEATURES['ENABLE_CREATOR_GROUP'] = True
    FEATURES['STUDIO_REQUEST_EMAIL'] = '[email protected]'
    
  6. Go to the Studio home page and sign up a new user: http://localhost:18010/
  7. Expand the "Becoming a Course Creator in Studio" box to request course creation access (this is optional -- an "unrequested" entry is created even if you don't request one, and you can approve that below.)
  8. Login to Studio Django Admin in another window as a superuser (http://localhost:18010/admin, [email protected] / edx)
  9. Create a new Organization, e.g. with Name: OpenCraft, Short Name: OC
  10. Navigate to [Course creators|http://localhost:18010/admin/course_creators/coursecreator/] and mark the request granted, and select the OpenCraft organization as the only org you can create courses for.

From here, you'll have to play around in the shell, because we only have Django Admin capabilities for ContentTaxonomies right now, and you have to be global staff to access Django Admin, which doesn't let us test out our org restrictions.

For example:

# make studio-shell
root@lms:/edx/app/edxapp/edx-platform# ./manage.py cms shell

from django.contrib.auth import get_user_model
# user you created
org_user = get_user_model().objects.get(username='openedx')
# demo users automatically created
learner = get_user_model().objects.get(username='honor')
staff_user = get_user_model().objects.get(username='staff')

from openedx.features.content_tagging import models, rules, api

from organizations.models import Organization
oc = Organization.objects.get(short_name="OC")
org_taxonomy = api.create_taxonomy(name="OpenCraft taxonomy", org_owners=[oc])
org_taxonomy
# <Taxonomy object (2)>
assert org_user.has_perm('oel_tagging.add_taxonomy', org_taxonomy)
assert org_user.has_perm('oel_tagging.change_taxonomy', org_taxonomy)
assert not learner.has_perm('oel_tagging.add_taxonomy')
assert not learner.has_perm('oel_tagging.change_taxonomy', org_taxonomy)
assert not learner.has_perm('oel_tagging.add_taxonomy', org_taxonomy)

Deadline

None

Other information

Depends on openedx/openedx-learning#62 and openedx/openedx-learning#65

Data migrations added here can be easily rolled back.

Course creator groups added by #26616.

Author to do before merge:

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 6, 2023
@openedx-webhooks
Copy link

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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

Copy link
Contributor

@ChrisChV ChrisChV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pomegranited I left a minor comment, but it looks good to me 👍

  • I tested folowing the testing instructions
  • I read through the code and tests with care

@pomegranited pomegranited requested a review from ormsbee July 12, 2023 06:22
@pomegranited pomegranited force-pushed the jill/add-content-tagging-smart-objecttags branch from fb4a1e2 to 19e3663 Compare July 13, 2023 05:29
@ChrisChV
Copy link
Contributor

@pomegranited 👍 to the new changes

  • I tested folowing the testing instructions
  • I read through the code and tests with care

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just minor comments. I do hope that we can simplify the casting/validation even more in the future.

@@ -3217,6 +3217,10 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
# Course Goals
'lms.djangoapps.course_goals.apps.CourseGoalsConfig',

# Tagging
'openedx_tagging.core.tagging.apps.TaggingConfig',
'openedx.features.content_tagging',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This can come in a separate PR)

It would be good to add openedx.features.content_tagging to mypy.ini so you get static type checking, and to setup.cfg isolated_apps so you can make sure all other parts of the code are only importing from content_tagging.api. I think you can add openedx_tagging.core.tagging to isolated_apps as well to make sure we're only importing from api.

Copy link
Contributor Author

@pomegranited pomegranited Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oo that's very cool.. will remember this for a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openedx/features/content_tagging/api.py Outdated Show resolved Hide resolved
openedx/features/content_tagging/api.py Outdated Show resolved Hide resolved
openedx/features/content_tagging/models.py Outdated Show resolved Hide resolved
openedx/features/content_tagging/models.py Outdated Show resolved Hide resolved
openedx/features/content_tagging/models.py Outdated Show resolved Hide resolved
openedx/features/content_tagging/models.py Outdated Show resolved Hide resolved
@pomegranited pomegranited force-pushed the jill/add-content-tagging-smart-objecttags branch from ef6d2f9 to 0e86583 Compare July 24, 2023 06:44
@bradenmacdonald
Copy link
Contributor

@pomegranited Let me know when the pypi thing is fixed, and I'll merge this for you.

@pomegranited pomegranited force-pushed the jill/add-content-tagging-smart-objecttags branch from 76d8dcc to 1a3c38f Compare July 26, 2023 04:51
@pomegranited
Copy link
Contributor Author

@bradenmacdonald Resolved :) requirements/edx/kernel.in#L118

I also squashed my commits down and rebased on latest master. Ready whenever you are, and thank you so much for your guidance here!

from cms.djangoapps.contentstore.helpers to common.djangoapps.student.auth
Adds models and APIs to support tagging content objects (e.g. XBlocks,
content libraries) by content authors. Content tags can be thought of as
"name:value" fields, though underneath they are a bit more complicated.

* adds dependency on openedx-learning<=0.1.0
* adds tagging app to LMS and CMS
* adds content tagging models, api, rules, admin, and tests.
* content taxonomies and tags can be maintained per organization by
  content creators for that organization.
@pomegranited pomegranited force-pushed the jill/add-content-tagging-smart-objecttags branch from 1a3c38f to 6206316 Compare July 26, 2023 05:14
@bradenmacdonald bradenmacdonald merged commit 8098169 into openedx:master Jul 26, 2023
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants