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

fix: allow users who can create orgs to see the full list of orgs when creating a course [FC-0076] #1689

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Feb 25, 2025

Description

The fixes for #1577 caused issues with edx.org's Global Staff users not being able to create courses. edx.org/2U Global Staff are seeing an empty Organization drop-down list.

This issue arose due to misuse of two similarly-named flags returned by the contentstore's home API:

  • can_create_organizations: granted to Global Staff or everyone if FEATURES[ENABLE_CREATOR_GROUP] == True, cf code
  • allow_to_create_new_org: which is actually about auto-creating organizations, so both can_create_organizations + settings.ORGANIZATIONS_AUTOCREATE must be True, cf code

In this change, we use canCreateOrganizations to decide whether the user can see the full list of organizations when creating courses. We preserve the use of allowToCreateNewOrg when deciding whether to allow users to "typeahead" to create a new organization not in the drop-down list.

Supporting information

Testing instructions

  1. Set ORGANIZATIONS_AUTOCREATE = False to disallow org auto-creation when creating courses or libraries.
  2. Ensure one or more organizations are created in Django Admin.
  3. Login as a Global Staff user.
  4. Click "New course"
    Ensure you can select from the full list of organizations in the list, and that you're not allowed to type in a new organization name when creating a course.
  5. Login as a non-Global Staff, Org Admin user for one of the existing orgs.
  6. Click "New course"
    Ensure you can only select your one org from the list, and that you can create courses in that org.

Repeat the above steps with the default ORGANIZATIONS_AUTOCREATE = True:

  1. Global Staff users should be allowed to type in a new organization when creating courses.
  2. Org Admins should not be allowed to type in a new organization when creating courses.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Feb 25, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Feb 25, 2025

Thanks for the pull request, @pomegranited!

This repository is currently maintained by @openedx/2u-tnl.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.35%. Comparing base (8fe52d2) to head (91965a0).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1689      +/-   ##
==========================================
- Coverage   93.35%   93.35%   -0.01%     
==========================================
  Files        1109     1109              
  Lines       22103    22103              
  Branches     4681     4763      +82     
==========================================
- Hits        20635    20634       -1     
- Misses       1403     1404       +1     
  Partials       65       65              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pomegranited pomegranited marked this pull request as ready for review February 25, 2025 23:40
@pomegranited pomegranited added the FC Relates to an Axim Funded Contribution project label Feb 25, 2025
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.

Looks good 👍

  • I tested this: I followed the testing instructions in detail
  • I read through the code and considered the security, stability and performance implications of the changes.
  • Includes tests for bugfixes and/or features added.
  • Includes documentation

@ChrisChV ChrisChV merged commit e5360dc into openedx:master Feb 26, 2025
7 checks passed
@pomegranited pomegranited deleted the jill/allow-staff-to-see-all-orgs branch February 26, 2025 02:10
@pomegranited
Copy link
Contributor Author

@hinakhadim Could you let us know whether this fixes the issue for your team? Then I'll backport it to Sumac.

@hinakhadim
Copy link
Contributor

Thank you so much, @pomegranited, for the quick fix. Staff users can now create courses successfully. You can backport it to Sumac.

However, the organization dropdown is quite long, requiring manual scrolling to find the desired organization (zoomed-out image attached). Ideally, we should be able to search for an organization using an input box and select it. Since this is a separate issue, I will create a new ticket for it.

image

pomegranited added a commit to open-craft/frontend-app-authoring that referenced this pull request Feb 26, 2025
…n creating a course [FC-0076] (openedx#1689)

The fixes for openedx#1577 caused issues with edx.org's Global Staff users not being able to create courses. edx.org/2U Global Staff are seeing an empty Organization drop-down list.

This issue arose due to misuse of two similarly-named flags returned by the contentstore's home API

* `can_create_organizations`: granted to Global Staff or everyone if `FEATURES[ENABLE_CREATOR_GROUP] == True`,
* `allow_to_create_new_org`: which is actually about auto-creating organizations, so both `can_create_organizations` + `settings.ORGANIZATIONS_AUTOCREATE` must be True

In this change, we use `canCreateOrganizations` to decide whether the user can see the full list of organizations when creating courses. We preserve the use of `allowToCreateNewOrg`  when deciding whether to allow users to "typeahead" to create a new organization not in the drop-down list.

(cherry picked from commit e5360dc)
ChrisChV pushed a commit that referenced this pull request Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project 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.

4 participants