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

feat: [FC-0031] Add optional field 'is_enrolled' to course detail view #33646

Conversation

GlugovGrGlib
Copy link
Member

Description

In this PR, the is_enrolled parameter is included in the CourseDetailView endpoint's response when the optional username query parameter is provided.

Supporting information

This contribution is a part of the FC-0031

Testing instructions

GET /api/mobile/v3/course_info/{course_key}/info

See that "is_enrolled" is present in the response

Other information

The rejected implementation for the mobile endpoint can be found in #33297

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

Thanks for the pull request, @GlugovGrGlib! 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.

@GlugovGrGlib
Copy link
Member Author

Hi @feanil can you please review this, this is the refactored version of the #33297

"""
response = super().to_representation(instance)
if can_show_certificate_available_date_field(instance):
response['certificate_available_date'] = instance.certificate_available_date

requested_user = self.context['request'].query_params.get('username', None)
if self.context['request'].user.is_authenticated and requested_user:
Copy link
Contributor

Choose a reason for hiding this comment

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

This would let any user look up the enrollment status for any other user, I think we would only want to allow that if the user is a staff user and otherwise, we should only provide this info in the requested user is the same as the authenticated user.

Alternatively, we could just flag this on if an authenticated user is making the call and provide the authenticated users enrollment status in that case. This might be simpler?

Copy link
Member Author

Choose a reason for hiding this comment

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

@feanil The code was updated to follow proposed logic, please review

Copy link
Contributor

@moeez96 moeez96 left a comment

Choose a reason for hiding this comment

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

Agreed with comments above, the approach LGTM.

@KyryloKireiev KyryloKireiev force-pushed the rg/feat/FC0031/update_course_detail_view_endpoint branch from d2cab9a to b3e0aea Compare December 15, 2023 12:28
@e0d
Copy link
Contributor

e0d commented Dec 15, 2023

@feanil I believe your comments have been addressed.

Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

Updates to the API look great, but I had a question about some other files that got added. If we can drop those, I think the rest of this is good to merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this added to the PR? is this a mistake? This file is nearly empty because we're trying to get rid of it so if there is a reason for these override, I'd like to understand it so I can help find a better place for the overrides.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, sorry, this is mistake happened during rebase, will update this, thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here as in the other settings file:

Why was this added to the PR? is this a mistake? This file is nearly empty because we're trying to get rid of it so if there is a reason for these override, I'd like to understand it so I can help find a better place for the overrides.

if requested_username:
user = self.context['request'].user
if ((user.is_authenticated and user.username == requested_username)
or user.is_staff):
Copy link
Contributor

Choose a reason for hiding this comment

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

One more thing: I think this should also be allowed for is_superuser users. Can you add that as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, is_superuser status should be allowed to do this as well, thanks

@GlugovGrGlib GlugovGrGlib force-pushed the rg/feat/FC0031/update_course_detail_view_endpoint branch from b3e0aea to d344a7e Compare December 15, 2023 18:28
@feanil feanil merged commit 01fcbc9 into openedx:master Dec 15, 2023
64 checks passed
@openedx-webhooks
Copy link

@GlugovGrGlib 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot
Copy link
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
Contributor

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

1 similar comment
@edx-pipeline-bot
Copy link
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.

7 participants