-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: add taxonomies for org api #32871
feat: add taxonomies for org api #32871
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good @rpenido , especially the tests!
Let me know if you have any questions or objections to the changes I've suggested?
openedx/features/content_tagging/rest_api/v1/tests/test_views.py
Outdated
Show resolved
Hide resolved
openedx/features/content_tagging/rest_api/v1/tests/test_views.py
Outdated
Show resolved
Hide resolved
openedx/features/content_tagging/rest_api/v1/tests/test_views.py
Outdated
Show resolved
Hide resolved
openedx/features/content_tagging/rest_api/v1/tests/test_views.py
Outdated
Show resolved
Hide resolved
750daaa
to
0071e91
Compare
page_size = 100 | ||
max_page_size = 1000 | ||
|
||
pagination_class = TaxonomyPagination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, didn't notice that the pagination was only added here instead of on the openedx-learning side..
Do you mind to create a small PR against openedx-learning that moves this over there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToDo: remove pagination when the PR is merged:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your PR is merged and now available with openedx-learning==0.1.2
.
If you run make requirements
in your LMS shell, that should bump the installed version in the requirements/edx/*
files.
And if you run into this issue, see these comments on stackoverflow:
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
Thanks for the pull request, @rpenido! 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. |
97fe65b
to
ef81ea8
Compare
Hi @pomegranited! I reverted the changes that are not related to the Taxonomy model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rpenido , I've requested a few changes, and noted some things that I'd like to fix as part of a separate task.
I'm also awaiting word from Product on how they want the org content author permissions to work, something that came up in our last meeting. So this might sit in External Review for a little while before it can be merged.
But if you could address the requested changes, I'll work on the rest and let you know.
Thank you!
Hi @pomegranited! I made the changes and also reverted some "style only" modifications to get a clear diff. Thank you for your input on that. I will squash/rebase when we are ready to External Review! |
9f89936
to
36f8dcc
Compare
Hi @pomegranited !
|
36f8dcc
to
3dccf60
Compare
return queryset.filter(enabled=True).filter( | ||
Q( | ||
Exists( | ||
TaxonomyOrg.objects.filter( | ||
taxonomy=OuterRef("pk"), | ||
rel_type=TaxonomyOrg.RelType.OWNER, | ||
org=None, | ||
) | ||
) | ||
) | ||
| Q( | ||
Exists( | ||
TaxonomyOrg.objects.filter( | ||
taxonomy=OuterRef("pk"), | ||
rel_type=TaxonomyOrg.RelType.OWNER, | ||
org__short_name__in=[ | ||
org.short_name | ||
for org in Organization.objects.all() | ||
if is_taxonomy_user_for_org(request.user, org) | ||
], | ||
) | ||
) | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need the enabled
filter here -- the rest of this org checking can go.
return queryset.filter(enabled=True).filter( | |
Q( | |
Exists( | |
TaxonomyOrg.objects.filter( | |
taxonomy=OuterRef("pk"), | |
rel_type=TaxonomyOrg.RelType.OWNER, | |
org=None, | |
) | |
) | |
) | |
| Q( | |
Exists( | |
TaxonomyOrg.objects.filter( | |
taxonomy=OuterRef("pk"), | |
rel_type=TaxonomyOrg.RelType.OWNER, | |
org__short_name__in=[ | |
org.short_name | |
for org in Organization.objects.all() | |
if is_taxonomy_user_for_org(request.user, org) | |
], | |
) | |
) | |
) | |
) | |
return queryset.filter(enabled=True) |
Taxonomy users include global staff and superusers, course creators who can create courses for any org and | ||
content creators for this specific org. | ||
""" | ||
return is_content_creator(user, org.short_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted, we don't need any of this "is_content_creator" logic anymore. Only global staff + superusers can add/edit taxonomies, and anyone can view an enabled taxonomy, no matter its org.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
67ca1d8
to
c81c7bd
Compare
55696a8
to
210aed9
Compare
@rpenido Please fix the failing test and then I can merge this. |
7ee6d0b
to
3591589
Compare
Hi @bradenmacdonald! Do you know how to make the tests run again here? |
@rpenido They seem to be running now. |
I think we are good now @bradenmacdonald! Thank you! |
@bradenmacdonald I just rebased my PR open-craft#577 on @rpenido's work here. Was wondering if you'd like to take a take a look at it and merge it into this branch before merging this one in to master? Or are we better off doing it separately? The related openedx-learning PR openedx/openedx-learning#68 was already merged. |
@yusuf-musleh If it's just those two lines of code that were already approved, please go ahead and merge into this branch. Hope that's OK with you @rpenido. |
Of course @bradenmacdonald and @yusuf-musleh! Let's reduce the overhead and earn some time! |
@bradenmacdonald @rpenido Sounds good, I just need to bump up the installed version of the openedx-learning package. I'm currently running |
@bradenmacdonald Had to make a small change to the on the python API side and update the relevant tests. This is after the openedx-learning version upgrade. Tests should be fixed now, waiting for them to complete, then will merge, unless you have any issues with the additional changes I added. |
07b8e9a
to
a19b2ea
Compare
# openedx-learning new version has some changes which are breaking quality tests | ||
# See https://github.com/openedx/openedx-learning/pull/68 for the changes. | ||
# It needs to be updated in a separate issue. | ||
openedx-learning==0.1.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bradenmacdonald I removed this to make the tests pass. I'm not sure what "breaking quality tests" means here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rpenido I believe that was because when my changes were merged to the openedx-learning
repo, it contained changes that remove some kwargs from some functions that were being called in this repo, and that would cause the quality tests to fail (hence the version was pinned to not use the latest). Now that everything is being merged, this change should be fine, in fact, it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @yusuf-musleh!
Hi @bradenmacdonald! Thank you! |
@rpenido Thanks for the ping; I actually didn't realize this was waiting for me. I'll merge it in 30 min. |
@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
Description
This PR adds support for creating, viewing, updating and deleting Taxonomies for Organizations via REST APIs, with the permissions applied accordingly.
Supporting information
Testing instructions
test_views.py
andtest_rules.py
are correct.Manual check can be done in the CMS App:
Private-ref: FAL-3450