-
Notifications
You must be signed in to change notification settings - Fork 2
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
Department REST API #1877
Department REST API #1877
Conversation
This PR is branched from #1872 and should be blocked until that PR is merged. |
Why just the nr of course and not the list of courses ? Is there any api/departments/[departmentid]/courses endpoint ? |
@Ferdi I was thinking about including the list of course ID's since you could then use those to make a second API call to retrieve the courses themselves. I didn't want this endpoint to become a substitute for the courses endpoint by including too much course information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work OK but there's some weirdness with the DRF frontend noted below.
courses/views/v1/__init__.py
Outdated
queryset = Department.objects.annotate( | ||
courses=Count("course"), programs=Count("program") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be moved to a get_queryset
? It breaks rendering with the DRF frontend otherwise - if you just try to hit the API from the browser directly, you get a 500 error because there's no queryset
property on the class. (It's fine from within the app or if you set ?format=json
, so this just affects the frontend that DRF adds on.)
@collinpreston thanks, is there any endpoint do you get a list of courses in a given department (api/departments/[departmentid]/courses ) ? |
@Ferdi , there is not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This reverts commit f49e9c6.
This reverts commit f49e9c6.
What are the relevant tickets?
#1876
Description (What does it do?)
Adds a REST API endpoint for retrieving departments in MITx Online. The endpoint is http://mitxonline.odl.local:8013/api/departments. The data returned from the endpoint is:
Calls to this endpoint are added from the catalog page in order to display all departments for courses or programs upon initial load of the page.
Departments are only displayed based on the following:
How can this be tested?
Additional Context
There is the possibility that a department is associated with 1 or more courses or programs that will not be visible on the catalog page due to the catalogs business logic for filtering courses and programs. The department will still be shown.