-
Notifications
You must be signed in to change notification settings - Fork 16
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: added filter for modifying the isStarted for externally hosted … #106
feat: added filter for modifying the isStarted for externally hosted … #106
Conversation
@felipemontoya could you please review my PR? I have to ship these changes as soon as possible. |
Hi @jajjibhai008 , thanks for tagging me. Do you have the link to the corresponding edx-platform pr? I am not understanding the goal of this filter by looking at the definition alone. |
Hi @felipemontoya, Here is the edx-platform PR: openedx/edx-platform#32788 |
Thanks a lot. Now I understand much better. I think the definition of the filter is too specific to make it a reusable filter. You have: But in order to truly pinpoint the filtered situation it would have to be: I think you could refactor this a bit to make it global to the whole API call. Broadly speaking you could let the serializer run its whole logic and then add a filter that lets you work on the final result. class EnrollmentSerializer(serializers.Serializer):
def to_representation(self, instance):
"""Let the filter work after the whole instance is serialized"""
ret = super().to_representation(instance)
ret = CourseEnrollmentAPIRendered().run_filter(representation=ret)
return ret So you could have a filter whose domain is: Such a filter could be re used in the future when you want to alter any of the fields of this API |
Now that I think of it, maybe you would rather filter the instance object before is passed to |
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 per the comment above
HI @felipemontoya Thanks for your detailed review.
|
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.
hey @jajjibhai008, I'm happy that the review helped.
I'd still like to understand something. You changed the position of the filter to a position where you can have an effect on all the fields for this API. But you are still defining the filter in a way that would only let a developer using the filter change the is_started
value. I would still suggest that you change the definition so that by opening the capability to alter the API you are actually allowing the complete set of fields to be worked on.
Then you could call the filter "org.openedx.learning.home.enrollment.api.rendered.v1"
and allow other features in the future to build on top of this.
@felipemontoya I have updated the filter definition to |
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.
Thanks @jajjibhai008. I would say codewise this looks good now.
I don't have access to any of the Jira tickets you linked so I have no Idea about how this fullfills or not the requirement, but I'll leave my review approval
Thanks, @felipemontoya for your kind and experienced reviews. |
Could someone else from your team that has access to the jira tickets give a review as well? I have no context from the requirements other that what is in this page. |
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.
Awesome Work!
Description:
This PR adds a filter for modifying the
isStarted
for externally hosted courses. This hook will identify whether the learner has started the course or not.Reference:
Actually, this field will be used to identify whether the learner has started the course or not. And we will conditionally render some things on the learner dashboard (B2C side) as described in ENT-7188.
JIRA- ENT-7373 and ENT-at 7374
Dependencies: dependencies on other outstanding PRs, issues, etc.
Merge deadline: List merge deadline (if any)
Installation instructions: List any non-trivial installation
instructions.
Testing instructions:
Reviewers:
Merge checklist:
Post merge:
finished.
Author concerns: List any concerns about this PR - inelegant
solutions, hacks, quick-and-dirty implementations, concerns about
migrations, etc.