BB-547 - Fix certificate api when retrieving certificates from deleted courses (WIP)

Description

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.

*Testing instructions:*
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.

*Reviewers*

  • [ ] @xitij2000

  • [ ] edX reviewer[s] TBD

Assignee

David Ormsbee

Reporter

Open Source Pull Request Bot

Contributor Name

Giovanni Cimolin da Silva

Repo

edx/edx-platform

Customer

Epic Link

None

OSCM Assignee

None

Platform Map Area (Levels 1 & 2)

Learner Experiences - Credentials

Platform Map Area (Levels 3 & 4)

Certificates

Blended Hour Utilization Percentage

None

Priority

Unset
Configure