-
Notifications
You must be signed in to change notification settings - Fork 2
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
Filter 'published' the same for /learningpaths and /learning_resource?resource_type=learning_path #71
Conversation
Codecov Report
@@ Coverage Diff @@
## main #71 +/- ##
=======================================
Coverage 84.17% 84.18%
=======================================
Files 401 401
Lines 16968 16969 +1
Branches 2707 2707
=======================================
+ Hits 14283 14285 +2
Misses 2368 2368
+ Partials 317 316 -1
|
|
||
published_filter = Q(published=True) | ||
|
||
if is_learning_path_editor(self.request) or is_admin_user(self.request): |
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 originally thought of this read-only viewset as intended just for browsing published resources, and if one needed to do any CRUD work, a different endpoint would be used (only LearningPath fits that need right now). I'm fine with discarding that assumption, but one potential issue with this change is that editors/admins will always see both published and unpublished results here for learning paths, and there may be times when it is only appropriate to show published paths (for instance, a carousel of top 10 newest learning paths or top 10 newest resources in general). One way to avoid this is to add published
to the filterset_fields
above, and filter by ?published=true
whenever necessary. Can you add that in?
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.
PS One potential drawback to this though is that using ?published=False
would allow any users to see unpublished courses, programs, videos, paths, etc - which may or may not be desirable? So might need to somehow force published=True
for anyone except admins (and editors for learningpaths only)
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.
Maybe add an api/v1/learning_resources/published/
endpoint to be used by carousels and such? And leave the code above as is (editors/admins always see published + unpublished paths unless using the /published/ endpoint).
@ChristopherChudzicki can you summarize what the changes are ? |
@Ferdi My goal with this change was to make it so that if a user has permission view a learningpath, then it is visible at
I was not thinking to use the For example: the frontend caches API responses. If we sometimes request LearningPaths from @mbertrand Re
Good point. If we do change this API, then rather than explicitly saying "published only", maybe |
@mbertrand I'm going to close this for now, but I'll leave the issue open: For the learningpaths work, You raise a good point point about published filtering; I left a note about that in #67 |
What are the relevant tickets?
A potential fix for #67
What's this PR do?
This PR refactors how the published filtering works so that
/learningpaths
and/learning_resources?resource_type=learning_path
return the same results.How should this be manually tested?
learning_path_editor
permission (or as admin).learning_path_editor
permission (or as admin).