Skip to content

Conversation

@shanbady
Copy link
Contributor

What are the relevant tickets?

Closes #556

Description (What does it do?)

This Pr adds an api endpoint (/api/v0/program_certificates) to retrieve program certificates along with program letter urls for an authenticated user. The idea is that when a user goes to a program specific dashboard, we will call this endpoint to get a list of program letter urls to display.

How can this be tested?

  1. checkout this branch and generate some program certificates via

from profiles.models import ProgramCertificate
ProgramCertificate.objects.get_or_create(user_full_name='john doe',user_email='your@email.here', micromasters_program_id=1, program_title='Supply Chain Management')
ProgramCertificate.objects.get_or_create(user_full_name='john doe',user_email='your@email.here', micromasters_program_id=18, program_title='Statistics and Data Science')
ProgramCertificate.objects.get_or_create(user_full_name='john doe',user_email='your@email.here', micromasters_program_id=2, program_title='Data, Economics, and Development Policy')
  1. visit endpoint http://localhost:8063/api/v0/program_certificates/ and confirm they your program certificates are listed there along with the program_letter_urls

@codecov
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.81%. Comparing base (f125f24) to head (20d3eb7).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #608      +/-   ##
==========================================
+ Coverage   74.73%   74.81%   +0.07%     
==========================================
  Files         245      245              
  Lines       11170    11204      +34     
  Branches     1943     1947       +4     
==========================================
+ Hits         8348     8382      +34     
  Misses       2648     2648              
  Partials      174      174              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shanbady shanbady marked this pull request as ready for review March 13, 2024 12:41
@shanbady shanbady added Needs Review An open Pull Request that is ready for review and removed Work in Progress labels Mar 13, 2024
@mbertrand mbertrand self-assigned this Mar 13, 2024
Copy link
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

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

Looks good, but have some questions about the returned url and format.

return reverse(
"profile:program-letter-intercept", args=[instance.micromasters_program_id]
)

Copy link
Member

Choose a reason for hiding this comment

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

This is returning urls in the format "/program_letter/1/", which will only work for the certificate's logged-in user. Wondering if maybe it should provide the shareable url instead if it exists yet (/program_letter/<uuid>/view), or both as separate fields (something like create_letter_url, share_letter_url) since it's possible the shareable url hasn't yet been created?

Also, what do you think of returning absolute urls instead (http://<domain>/program_letter/....)? The frontend could create a full url itself, but maybe easier to do it in the backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mbertrand - made it generate absolute urls and changed the url params to return both a program_letter_generate_url and a program_letter_share_url. I also made it so the serializer itself does a get_or_create for the program letter. In the future we might consider removing the intercept view altogether but I think it still has a place for now (i'm imagning a case where we send links to view view a program letter from some marketing automation software that is only aware of program ids etc)

@shanbady shanbady requested a review from mbertrand March 13, 2024 18:23
Copy link
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

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

👍

@mbertrand mbertrand added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Mar 13, 2024
@shanbady shanbady merged commit 51587f1 into main Mar 13, 2024
@shanbady shanbady deleted the shanbady/endpoint-for-user-program-letter-info branch March 13, 2024 18:47
This was referenced Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create api endpoint for retrieving program letter info (or add program letter info to some other existing endpoint)

3 participants