Skip to content

Conversation

@sjasti-sonata-svg
Copy link

feat : [BE] Update Organizations Members API.
Update “Organizations Members” API to only fetch learner data.
This PR updates the existing Organization Members API to strictly return learner-type records for an enterprise customer. Previously, the API could return a mix of users with different roles
ENT-11260

@sjasti-sonata-svg sjasti-sonata-svg force-pushed the feat/update-org-members-API-learners-ENT-11260 branch from 3726ebe to 5a73629 Compare January 7, 2026 16:39
WHERE
ecu.enterprise_customer_id = %s
AND
AND
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove extra space

Copy link
Contributor

@kiram15 kiram15 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 I would add a test to validate that it is no longer including users with the admin role here.

@sjasti-sonata-svg sjasti-sonata-svg force-pushed the feat/update-org-members-API-learners-ENT-11260 branch from 5fb55a8 to 5e12dea Compare January 8, 2026 18:54
@sjasti-sonata-svg
Copy link
Author

Hi @kiram15 ,
Here I am attaching the screenshot of unit test cases for this. It is running in my local and tests are passing as well.
Screenshot 2026-01-08 234135

return response.Response(
{"detail": "Could not find enterprise uuid {}".format(enterprise_uuid)},
status=status.HTTP_404_NOT_FOUND,
except OperationalError as exc:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comment

Copy link
Author

Choose a reason for hiding this comment

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

Hi @msaha-sonata ,
Added comments.

@sjasti-sonata-svg sjasti-sonata-svg force-pushed the feat/update-org-members-API-learners-ENT-11260 branch 4 times, most recently from e94d224 to da135d5 Compare January 12, 2026 19:43
Copy link
Contributor

@msaha-sonata msaha-sonata 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 to me

Copy link
Contributor

@kiram15 kiram15 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 I'm confused why you have a similar one open without the tests? I think this should be the only one that is merged in.

Copy link
Contributor

@pwnage101 pwnage101 left a comment

Choose a reason for hiding this comment

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

The query SQL change looks good, but I have a concern about the exception handler fallback logic.

Comment on lines 155 to 161
# Fallback query without auth_userprofile
fallback_query = query.replace(
"LEFT JOIN auth_userprofile as aup on au.id = aup.user_id",
""
).replace(
"coalesce(NULLIF(aup.name, ''), au.username)",
"au.username"
Copy link
Contributor

Choose a reason for hiding this comment

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

In my opinion, this kind of SQL manipulation is extremely risky. Are you sure auth_userprofile is sometimes missing in test/minimal environments? The UserProfile model does not seem optional.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @pwnage101
I worked on your comments. could you please check once let me the same.

…ializers, and tests

- Added comments to EnterpriseCustomerAdmin and EnterpriseCustomerMembers
- Updated views and serializer tests for learners vs admins
- Verified invited_date and joined_date handling in tests
@sjasti-sonata-svg sjasti-sonata-svg force-pushed the feat/update-org-members-API-learners-ENT-11260 branch from ac2c05a to 9e107ea Compare January 24, 2026 10:12
@staticmethod
def has_auth_userprofile_table():
"""
Some minimal / test Open edX environments do not include auth_userprofile.
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did you learn this?

Copy link
Author

Choose a reason for hiding this comment

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

Hi @pwnage101
I actually I didn't understand your question.
can you please elaborate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Your code states "Some minimal / test Open edX environments do not include auth_userprofile."

I don't think this is true, so I am curious where you learned this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants