Fix a problem with the Certificates API that make it fail when trying to retrieve user certificates from courses that don't exist anymore. The problem lies in the Certificate API not checking if the courses being retrieved by some user actually exist.
This issue was found when investigating why a user profile page (/u/username) was returning 404's. Turns out that *LearnerAchievementsFragmentView* used the certificates api to retrieve certificate information, which did not check if the course exists before trying to pull information from it, resulting in a cascade of errors that lead to a 404 on the user's profile page.
The issue happens at line *37* of file /home/giovanni-opencraft/opencraft/edx-platform/openedx/features/learner_profile/views/learner_achievements.py:
course_certificates = certificate_api.get_certificates_for_user(username)
*JIRA tickets*: --.
*Sandbox URL*: TBD - sandbox is being provisioned.
*Merge deadline*: None.
1. Creating a test course.
2. Giving a user a certificate in this course.
3. Deleting this test course.
4. Accessing the user's profile before and after the fix.
*Author notes and concerns*:
1. This is a fix for existing views and to make the Certificates API more error tolerant. I think that a fix on methods that delete courses is needed to prevent this kind on inconsistencies.
[ ] @xitij2000
[ ] edX reviewer[s] TBD