Skip to content

feat: adds Content Tagging - #32661

Merged
bradenmacdonald merged 2 commits into
openedx:masterfrom
open-craft:jill/add-content-tagging-smart-objecttags
Jul 26, 2023
Merged

feat: adds Content Tagging#32661
bradenmacdonald merged 2 commits into
openedx:masterfrom
open-craft:jill/add-content-tagging-smart-objecttags

Conversation

@pomegranited

@pomegranited pomegranited commented Jul 6, 2023

Copy link
Copy Markdown
Contributor

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-core#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'] = 'your@email.com'
    
  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, edx@example.com / 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-core#62 and openedx/openedx-core#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
Copy Markdown

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.

Comment thread requirements/edx/kernel.in Outdated
Comment thread openedx/features/content_tagging/models.py Outdated

@ChrisChV ChrisChV left a comment

Copy link
Copy Markdown
Contributor

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
Comment thread openedx/features/content_tagging/models.py Outdated
Comment thread openedx/features/content_tagging/models.py Outdated
Comment thread requirements/common_constraints.txt Outdated
Comment thread openedx/features/content_tagging/models.py Outdated
@ChrisChV

Copy link
Copy Markdown
Contributor

@pomegranited 👍 to the new changes

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

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread lms/envs/common.py

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

Copy link
Copy Markdown
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.

@pomegranited pomegranited Jul 24, 2023

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

1 similar comment
@edx-pipeline-bot

Copy link
Copy Markdown
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