Skip to content

Commit

Permalink
Rename public_id query param to org_public_id (#6547)
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya authored Aug 9, 2024
1 parent e668244 commit adf4c6a
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lms/services/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def delete_dashboard_admin(self, dashboard_admin_id: int) -> None:
def get_request_admin_organizations(self, request) -> list[Organization]:
"""Get the organization the current user is an admin in."""
if request.has_permission(Permissions.STAFF) and (
request_public_id := request.params.get("public_id")
request_public_id := request.params.get("org_public_id")
):
# We handle permissions and filtering specially for staff members
# If the request contains a filter for one organization, we will proceed as if the staff member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function AllCoursesActivity() {
h_userid: studentIds,
assignment_id: assignmentIds,
course_id: courseIds,
public_id: organizationPublicId,
org_public_id: organizationPublicId,
});
const rows: CoursesTableRow[] = useMemo(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function AssignmentActivity() {
{
h_userid: studentIds,
assignment_id: assignmentId,
public_id: organizationPublicId,
org_public_id: organizationPublicId,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function CourseActivity() {
{
assignment_id: assignmentIds,
h_userid: studentIds,
public_id: organizationPublicId,
org_public_id: organizationPublicId,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function DashboardActivityFilters({
() => ({
h_userid: students.selectedIds,
assignment_id: selectedAssignmentIds,
public_id: organizationPublicId,
org_public_id: organizationPublicId,
}),
[organizationPublicId, selectedAssignmentIds, students.selectedIds],
);
Expand All @@ -113,7 +113,7 @@ export default function DashboardActivityFilters({
() => ({
h_userid: students.selectedIds,
course_id: selectedCourseIds,
public_id: organizationPublicId,
org_public_id: organizationPublicId,
}),
[organizationPublicId, selectedCourseIds, students.selectedIds],
);
Expand All @@ -132,7 +132,7 @@ export default function DashboardActivityFilters({
() => ({
assignment_id: selectedAssignmentIds,
course_id: selectedCourseIds,
public_id: organizationPublicId,
org_public_id: organizationPublicId,
}),
[organizationPublicId, selectedAssignmentIds, selectedCourseIds],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,23 @@ describe('AllCoursesActivity', () => {
h_userid: ['123', '456'],
assignment_id: [],
course_id: [],
public_id: undefined,
org_public_id: undefined,
});

updateFilter('assignments', ['1', '2']);
assertCoursesFetched({
h_userid: [],
assignment_id: ['1', '2'],
course_id: [],
public_id: undefined,
org_public_id: undefined,
});

updateFilter('courses', ['3', '8', '9']);
assertCoursesFetched({
h_userid: [],
assignment_id: [],
course_id: ['3', '8', '9'],
public_id: undefined,
org_public_id: undefined,
});
});

Expand All @@ -208,15 +208,13 @@ describe('AllCoursesActivity', () => {
fakeUseParams.returns({ organizationPublicId: 'the-org-public-id' });
});

it('propagates public_id to API calls', () => {
it('propagates org_public_id to API calls', () => {
createComponent();

assert.calledWith(
fakeUseAPIFetch.lastCall,
sinon.match.string,
sinon.match({
public_id: 'the-org-public-id',
}),
sinon.match({ org_public_id: 'the-org-public-id' }),
);
});
});
Expand All @@ -232,7 +230,7 @@ describe('AllCoursesActivity', () => {
h_userid: [],
assignment_id: [],
course_id: [],
public_id: undefined,
org_public_id: undefined,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe('AssignmentActivity', () => {
assert.calledWith(fakeUseAPIFetch.lastCall, sinon.match.string, {
h_userid: ['1', '2'],
assignment_id: '123',
public_id: undefined,
org_public_id: undefined,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('CourseActivity', () => {
assert.calledWith(fakeUseAPIFetch.lastCall, sinon.match.string, {
assignment_id: ['1', '2'],
h_userid: ['3'],
public_id: undefined,
org_public_id: undefined,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ describe('DashboardActivityFilters', () => {
{
h_userid: selectedStudentIds,
assignment_id: selectedAssignmentIds,
public_id: undefined,
org_public_id: undefined,
},
);
assert.calledWith(
Expand All @@ -399,7 +399,7 @@ describe('DashboardActivityFilters', () => {
{
h_userid: selectedStudentIds,
course_id: selectedCourseIds,
public_id: undefined,
org_public_id: undefined,
},
);
assert.calledWith(
Expand All @@ -409,7 +409,7 @@ describe('DashboardActivityFilters', () => {
{
assignment_id: selectedAssignmentIds,
course_id: selectedCourseIds,
public_id: undefined,
org_public_id: undefined,
},
);
});
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/lms/services/dashboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_get_organizations_by_admin_email(
}

def test_get_request_admin_organizations_for_non_staff(self, pyramid_request, svc):
pyramid_request.params = {"public_id": sentinel.public_id}
pyramid_request.params = {"org_public_id": sentinel.public_id}

assert not svc.get_request_admin_organizations(pyramid_request)

Expand All @@ -167,7 +167,7 @@ def test_get_request_admin_organizations_no_organization(
):
pyramid_config.testing_securitypolicy(permissive=True)
organization_service.get_by_public_id.return_value = None
pyramid_request.params = {"public_id": sentinel.public_id}
pyramid_request.params = {"org_public_id": sentinel.public_id}

with pytest.raises(HTTPNotFound):
svc.get_request_admin_organizations(pyramid_request)
Expand All @@ -178,7 +178,7 @@ def test_get_request_admin_organizations(
pyramid_config.testing_securitypolicy(permissive=True)
organization_service.get_by_public_id.return_value = organization
organization_service.get_hierarchy_ids.return_value = [organization.id]
pyramid_request.params = {"public_id": sentinel.public_id}
pyramid_request.params = {"org_public_id": sentinel.public_id}

assert svc.get_request_admin_organizations(pyramid_request) == [organization]
organization_service.get_by_public_id.assert_called_once_with(
Expand All @@ -189,7 +189,7 @@ def test_get_request_admin_organizations_for_staff(
self, svc, pyramid_config, pyramid_request, organization, organization_service
):
pyramid_config.testing_securitypolicy(permissive=True)
pyramid_request.params = {"public_id": sentinel.id}
pyramid_request.params = {"org_public_id": sentinel.id}
organization_service.get_by_public_id.return_value = organization
organization_service.get_hierarchy_ids.return_value = [organization.id]

Expand Down

0 comments on commit adf4c6a

Please sign in to comment.