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

ENT-2117 | Adding enterprise_learner_portal djangoapp to house endpoi… #544

Merged
merged 1 commit into from
Aug 15, 2019

Conversation

christopappas
Copy link
Contributor

…nts needed for enterprise learner portal frontend

Description: Describe in a couple of sentence what this PR adds

JIRA: Link to JIRA ticket

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:

  1. Open page A
  2. Do thing B
  3. Expect C to happen
  4. If D happened instead - check failed.

Merge checklist:

  • New requirements are in the right place
    • base.in if needed in production, but edx-platform doesn't install it.
    • test-master.in if edx-platform pins it, with a matching version.
  • Regenerate requirements with make upgrade && make requirements (and make sure to fix any errors).
    DO NOT just add dependencies to requirements/*.txt files.
  • Called make static for webpack bundling if any static content was updated.
  • All reviewers approved
  • CI build is green
  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are (reasonably) squashed
  • Translations are updated
  • PR author is listed in AUTHORS

Post merge:

  • Create a tag
  • Check new version is pushed to PyPi after tag-triggered build is finished.
  • Delete working branch (if not needed anymore)
  • edx-platform PR (be sure to include edx-platform requirements upgrades that were present in this PR)

Author concerns: List any concerns about this PR - inelegant
solutions, hacks, quick-and-dirty implementations, concerns about
migrations, etc.




# course_run_status
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to write the logic for this still (porting it over from program_enrollment code in the platform)

'installed in an Open edX environment.')
)

user = get_object_or_404(User, email=user_email)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want this endpoint to return the enrollments for the authenticated user. The client should not be able to request a specific user with a query param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is your concern that someone viewing a page on the frontend could get information about other learners?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that would be a concern. We'd need to add an is_staff check in here to allow someone to request another user's enrollments. In general, though, I think this endpoint is designed to service the learner portal and in that context you would never need to request another user's enrollments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I can definitely make sure is_staff is a requirement.

As for the resource the endpoint uses to return data, the endpoint itself is more flexible if we don't limit it to the authenticated user. You could imagine a staff user having the option of checking data for number of users other than one's own. Especially where this is a new endpoint, I don't think we need to add this restriction just yet

from lms.djangoapps.program_enrollments.api.api import (
get_due_dates,
get_course_run_url,
get_emails_enabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

How many of these helper functions make DB calls or external API calls? I'm a bit worried about performance, but perhaps those concerns are premature at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some, but not all. https://github.com/edx/edx-platform/pull/21258/files in api/api.py. get_due_dates looks to be one that does

authentication_classes = (JwtAuthentication, BearerAuthentication, SessionAuthentication,)

def get(self, request, user_email):
if not request.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.

This will prevent non-staff users from using this endpoint. Keep it simple for now, just return enrollments for the request user. We can make this endpoint more flexible in the future when/if we need to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you help me to understand the value of changing what I've already written here? This seems to be more of a matter of preference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually @brittneyexline , do you have any sense of future product requirements that could guide this decision?

If we don't think we'll ever benefit from the way I've written this endpoint (specifically: being able to provide the email for any user), then I can change it

Copy link
Contributor

Choose a reason for hiding this comment

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

The way you have written it here will prevent this endpoint from being useable by the learner portal. Most enterprise learners will not be staff so when the frontend app makes a request to this endpoint they will get a 403 response.

Copy link
Contributor

@brittneyexline brittneyexline left a comment

Choose a reason for hiding this comment

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

i think you will have to modify setup.py to make sure this new package is getting exported. i would do a spot check to see if this app will be available when this branch is installed as the version of edx-enterprise to be sure.
other than that, this looks pretty good. i have one follow up i'd like to ask jennifer about around supporting multiple enterprises; but i would not worry about that in the scope of this ticket and PR.

)

user = request.user
enterprise_customer_user = get_object_or_404(
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm wondering if we should be mindful of having multiple enterprise's linked to the learner here. probably it would be best to follow up with separate work if we are trying to support this case... i will bring it up with jennifer to see her thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

we would like to have whatever we build support users linked to multiple enterprises, though we are not going to change any existing code unaffected by the scope of our project. i would recommend adding an enterprise id as a parameter passed into the path so that the endpoint will only return enrollments scoped to the enterprise. i leave it up to you to file a new story or complete the work with this story... i just don't want to forget about it 😄

overviews,
many=True,
context={
'user': enterprise_customer_user.user,
Copy link
Contributor

Choose a reason for hiding this comment

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

why add user here separately when the user is in the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, i think this is a vestige of the previous implementation (where we would want to serialize the data of the user whose email was handed to us)

)

user = request.user
enterprise_customer_user = get_object_or_404(
Copy link
Contributor

Choose a reason for hiding this comment

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

we would like to have whatever we build support users linked to multiple enterprises, though we are not going to change any existing code unaffected by the scope of our project. i would recommend adding an enterprise id as a parameter passed into the path so that the endpoint will only return enrollments scoped to the enterprise. i leave it up to you to file a new story or complete the work with this story... i just don't want to forget about it 😄

…nts needed for enterprise learner portal frontend

Fixing indent

Removing some whitespace

Adding logic to serializer to make sure it is installed into openedx instance

cleaning up imports;

Adding tests

Adding staff check on new endpoint. Also removing print statements

Attempting to fix travis build

Adding quality fixes

more quality fixes

Folding in refactors to get_course_run_status similar to what was done in edx-platform

Changing user to query for based on discussion. changing tests

Oops. missed a name change

Tweaks around serializer request/user

adding package to setup.py

Updating readme and changelog

Fixing changelog
@christopappas christopappas merged commit cd05c57 into master Aug 15, 2019
@christopappas christopappas deleted the cpappas/ENT-2117 branch August 15, 2019 16:28
tuchfarber added a commit that referenced this pull request Aug 16, 2019
…e endpoints needed for enterprise learner portal frontend (#544)"

This reverts commit cd05c57.
iloveagent57 pushed a commit that referenced this pull request Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants